Fix tevent_common_context_destructor to remove all events instead of just the first one
authorBo Yang <boyang@novell.com>
Sat, 10 Jan 2009 05:46:50 +0000 (13:46 +0800)
committerStefan Metzmacher <metze@samba.org>
Sun, 11 Jan 2009 14:26:47 +0000 (15:26 +0100)
Signed-off-by: Bo Yang <boyang@novell.com>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
lib/tevent/tevent.c

index c8b79c669c15e1367b5f56c3771b62a5e9cf0765..fa8219e2348e4f48b8a1b892dd106f5fc1808097 100644 (file)
@@ -147,19 +147,25 @@ int tevent_common_context_destructor(struct tevent_context *ev)
                ev->pipe_fde = NULL;
        }
 
-       for (fd=ev->fd_events; fd; fd = fd->next) {
+       fd = ev->fd_events;
+       while (fd) {
                fd->event_ctx = NULL;
                DLIST_REMOVE(ev->fd_events, fd);
+               fd = ev->fd_events;
        }
 
-       for (te=ev->timer_events; te; te = te->next) {
+       te = ev->timer_events;
+       while (te) {
                te->event_ctx = NULL;
-               DLIST_REMOVE(ev->timer_events, te);
+               DLIST_REMOVE(te->timer_events, te);
+               te = ev->timer_events;
        }
 
-       for (se=ev->signal_events; se; se = se->next) {
+       se = ev->signal_events;
+       while (se) {
                se->event_ctx = NULL;
                DLIST_REMOVE(ev->signal_events, se);
+               se = ev->signal_events;
        }
 
        return 0;