r25676: fixed a valgrind error in the epoll event backend. The linked list
authorAndrew Tridgell <tridge@samba.org>
Wed, 17 Oct 2007 10:00:30 +0000 (12:00 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 21 Dec 2007 04:43:09 +0000 (05:43 +0100)
could get mucked up.

source/lib/events/events_epoll.c

index e2212e533301f8194ce9fa6f3902dd54845e3260..109027eb1abbd49074724e7d009b6a44da3f2b58 100644 (file)
@@ -163,8 +163,6 @@ static void epoll_del_event(struct epoll_event_context *epoll_ev, struct fd_even
 {
        struct epoll_event event;
 
-       DLIST_REMOVE(epoll_ev->fd_events, fde);
-               
        if (epoll_ev->epoll_fd == -1) return;
 
        fde->additional_flags &= ~EPOLL_ADDITIONAL_FD_FLAG_REPORT_ERROR;
@@ -232,7 +230,6 @@ static void epoll_change_event(struct epoll_event_context *epoll_ev, struct fd_e
 
        /* there's no epoll_event attached to the fde */
        if (want_read || (want_write && !got_error)) {
-               DLIST_ADD(epoll_ev->fd_events, fde);
                epoll_add_event(epoll_ev, fde);
                return;
        }
@@ -353,6 +350,8 @@ static int epoll_event_fd_destructor(struct fd_event *fde)
        epoll_ev->num_fd_events--;
        epoll_ev->destruction_count++;
 
+       DLIST_REMOVE(epoll_ev->fd_events, fde);
+               
        epoll_del_event(epoll_ev, fde);
 
        if (fde->flags & EVENT_FD_AUTOCLOSE) {