lib/events: finish "Run only one event for each epoll_wait/select call"
authorStefan Metzmacher <metze@samba.org>
Mon, 18 Jan 2010 12:19:29 +0000 (13:19 +0100)
committerStefan Metzmacher <metze@samba.org>
Wed, 20 Jan 2010 08:44:35 +0000 (09:44 +0100)
This finished commit a78b8ea7168e5fdb2d62379ad3112008b2748576.

The logic was missing in events_standard (the one that's used by default).

metze

lib/events/events_epoll.c
lib/events/events_select.c
lib/events/events_standard.c

index 47bf2b3c3889194ad04f96d84a3354c43bddf6ad..053ae6117c13f36d3c4a4c9747989cb3edec1c18 100644 (file)
@@ -41,14 +41,6 @@ struct epoll_event_context {
        /* number of registered fd event handlers */
        int num_fd_events;
 
-       /* this is changed by the destructors for the fd event
-          type. It is used to detect event destruction by event
-          handlers, which means the code that is calling the event
-          handler needs to assume that the linked list is no longer
-          valid
-       */
-       uint32_t destruction_count;
-
        /* when using epoll this is the handle from epoll_create */
        int epoll_fd;
 
@@ -260,7 +252,6 @@ static int epoll_event_loop(struct epoll_event_context *epoll_ev, struct timeval
        int ret, i;
 #define MAXEVENTS 32
        struct epoll_event events[MAXEVENTS];
-       uint32_t destruction_count = ++epoll_ev->destruction_count;
        int timeout = -1;
 
        if (epoll_ev->epoll_fd == -1) return -1;
@@ -358,7 +349,6 @@ static int epoll_event_fd_destructor(struct fd_event *fde)
        epoll_check_reopen(epoll_ev);
 
        epoll_ev->num_fd_events--;
-       epoll_ev->destruction_count++;
 
        epoll_del_event(epoll_ev, fde);
 
index 885bd82590f91c1978c95dc8e95ed60e5fac4e50..4b60f4eb014778d84634a2c220674f769b430d8c 100644 (file)
@@ -48,10 +48,6 @@ struct select_event_context {
 
        /* information for exiting from the event loop */
        int exit_code;
-
-       /* this is incremented when the loop over events causes something which
-          could change the events yet to be processed */
-       uint32_t destruction_count;
 };
 
 /*
@@ -104,7 +100,6 @@ static int select_event_fd_destructor(struct fd_event *fde)
        }
 
        DLIST_REMOVE(select_ev->fd_events, fde);
-       select_ev->destruction_count++;
 
        if (fde->flags & EVENT_FD_AUTOCLOSE) {
                close(fde->fd);
@@ -180,7 +175,6 @@ static int select_event_loop_select(struct select_event_context *select_ev, stru
        fd_set r_fds, w_fds;
        struct fd_event *fde;
        int selrtn;
-       uint32_t destruction_count = ++select_ev->destruction_count;
 
        /* we maybe need to recalculate the maxfd */
        if (select_ev->maxfd == EVENT_INVALID_MAXFD) {
index fe128cac2a93ab667dc3ed1339d785b0925d0e67..6537d271d88199f80c57196ad2df8bf8705031fc 100644 (file)
@@ -51,14 +51,6 @@ struct std_event_context {
        /* information for exiting from the event loop */
        int exit_code;
 
-       /* this is changed by the destructors for the fd event
-          type. It is used to detect event destruction by event
-          handlers, which means the code that is calling the event
-          handler needs to assume that the linked list is no longer
-          valid
-       */
-       uint32_t destruction_count;
-
        /* when using epoll this is the handle from epoll_create */
        int epoll_fd;
 
@@ -255,7 +247,6 @@ static int epoll_event_loop(struct std_event_context *std_ev, struct timeval *tv
        int ret, i;
 #define MAXEVENTS 8
        struct epoll_event events[MAXEVENTS];
-       uint32_t destruction_count = ++std_ev->destruction_count;
        int timeout = -1;
 
        if (std_ev->epoll_fd == -1) return -1;
@@ -316,9 +307,7 @@ static int epoll_event_loop(struct std_event_context *std_ev, struct timeval *tv
                if (events[i].events & EPOLLOUT) flags |= EVENT_FD_WRITE;
                if (flags) {
                        fde->handler(std_ev->ev, fde, flags, fde->private_data);
-                       if (destruction_count != std_ev->destruction_count) {
-                               break;
-                       }
+                       break;
                }
        }
 
@@ -388,7 +377,6 @@ static int std_event_fd_destructor(struct fd_event *fde)
        }
 
        DLIST_REMOVE(std_ev->fd_events, fde);
-       std_ev->destruction_count++;
 
        epoll_del_event(std_ev, fde);
 
@@ -475,7 +463,6 @@ static int std_event_loop_select(struct std_event_context *std_ev, struct timeva
        fd_set r_fds, w_fds;
        struct fd_event *fde;
        int selrtn;
-       uint32_t destruction_count = ++std_ev->destruction_count;
 
        /* we maybe need to recalculate the maxfd */
        if (std_ev->maxfd == EVENT_INVALID_MAXFD) {
@@ -536,9 +523,7 @@ static int std_event_loop_select(struct std_event_context *std_ev, struct timeva
                        if (FD_ISSET(fde->fd, &w_fds)) flags |= EVENT_FD_WRITE;
                        if (flags) {
                                fde->handler(std_ev->ev, fde, flags, fde->private_data);
-                               if (destruction_count != std_ev->destruction_count) {
-                                       break;
-                               }
+                               break;
                        }
                }
        }