]> granicus.if.org Git - libevent/commitdiff
move EV_PERSIST handling out of the event backends
authorNiels Provos <provos@gmail.com>
Tue, 27 Nov 2007 01:39:10 +0000 (01:39 +0000)
committerNiels Provos <provos@gmail.com>
Tue, 27 Nov 2007 01:39:10 +0000 (01:39 +0000)
svn:r555

ChangeLog
epoll.c
event.c
evport.c
kqueue.c
poll.c
select.c

index c0364bcb6043dbd4ed5e46805d844d2340084635..a607749f66ad39c9904048f68e4848aac40bc502 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,7 @@ Changes in current version:
  o Add a more powerful evbuffer_readln as a replacement for evbuffer_readline.  The new function handles more newline styles, and is more useful with buffers that may contain a nul characters.
  o Do not mangle socket handles on 64-bit windows.
  o The configure script now takes an --enable-gcc-warnigns option that turns on many optional gcc warnings.  (Nick has been building with these for a while, but they might be useful to other developers.)
+ o move EV_PERSIST handling out of the event backends
 
 
 Changes in 1.4.0:
diff --git a/epoll.c b/epoll.c
index fdeb1e2a2232820412f4e728f61bc702aca2b6e0..06ff66a3c338c9529cdf0d25b965389292a52b90 100644 (file)
--- a/epoll.c
+++ b/epoll.c
@@ -230,12 +230,6 @@ epoll_dispatch(struct event_base *base, void *arg, struct timeval *tv)
                if (!(evread||evwrite))
                        continue;
 
-               if (evread != NULL && !(evread->ev_events & EV_PERSIST))
-                       event_del(evread);
-               if (evwrite != NULL && evwrite != evread &&
-                       !(evwrite->ev_events & EV_PERSIST))
-                       event_del(evwrite);
-
                if (evread != NULL)
                        event_active(evread, EV_READ, 1);
                if (evwrite != NULL)
diff --git a/event.c b/event.c
index 13662210b0e11762508a3b96447b940cfe5dd37d..a92d4f8066f7e4511a9d9880ee9c5c8abad4656f 100644 (file)
--- a/event.c
+++ b/event.c
@@ -336,9 +336,6 @@ event_process_active(struct event_base *base)
        int i;
        short ncalls;
 
-       if (!base->event_count_active)
-               return;
-
        for (i = 0; i < base->nactivequeues; ++i) {
                if (TAILQ_FIRST(base->activequeues[i]) != NULL) {
                        activeq = base->activequeues[i];
@@ -349,7 +346,10 @@ event_process_active(struct event_base *base)
        assert(activeq != NULL);
 
        for (ev = TAILQ_FIRST(activeq); ev; ev = TAILQ_FIRST(activeq)) {
-               event_queue_remove(base, ev, EVLIST_ACTIVE);
+               if (ev->ev_events & EV_PERSIST)
+                       event_queue_remove(base, ev, EVLIST_ACTIVE);
+               else
+                       event_del(ev);
                
                /* Allows deletes to work */
                ncalls = ev->ev_ncalls;
@@ -490,7 +490,6 @@ event_base_loop(struct event_base *base, int flags)
 
                res = evsel->dispatch(base, evbase, tv_p);
 
-
                if (res == -1)
                        return (-1);
 
index d3ba5960dc79aa887e13eae4d35246b2c91efbf1..76688e0e9219d1fd97810de5a50abfaa2b1ebe98 100644 (file)
--- a/evport.c
+++ b/evport.c
@@ -375,21 +375,16 @@ evport_dispatch(struct event_base *base, void *arg, struct timeval *tv)
                fdi = &(epdp->ed_fds[fd]);
 
                /*
-                * We now check for each of the possible events (READ or WRITE).
-                * If the event is not persistent, then we delete it. Then, we
-                * activate the event (which will cause its callback to be
-                * executed).
+                * We now check for each of the possible events (READ
+                * or WRITE).  Then, we activate the event (which will
+                * cause its callback to be executed).
                 */
 
                if ((res & EV_READ) && ((ev = fdi->fdi_revt) != NULL)) {
-                       if (!(ev->ev_events & EV_PERSIST))
-                               event_del(ev);
                        event_active(ev, res, 1);
                }
 
                if ((res & EV_WRITE) && ((ev = fdi->fdi_wevt) != NULL)) {
-                       if (!(ev->ev_events & EV_PERSIST))
-                               event_del(ev);
                        event_active(ev, res, 1);
                }
        } /* end of all events gotten */
index 1f2e35148e40b59b2c521c3b30d938ae562fe505..b241a9515300d555922902ba65099356744c8c58 100644 (file)
--- a/kqueue.c
+++ b/kqueue.c
@@ -278,7 +278,7 @@ kq_dispatch(struct event_base *base, void *arg, struct timeval *tv)
                        continue;
 
                if (!(ev->ev_events & EV_PERSIST))
-                       event_del(ev);
+                       ev->ev_flags &= ~EVLIST_X_KQINKERNEL;
 
                event_active(ev, which,
                    ev->ev_events & EV_SIGNAL ? events[i].data : 1);
diff --git a/poll.c b/poll.c
index f3f3420b68317d862af44aaac4d25099848525d9..9be42e17822e6e5abfe12c93444fff0db2e0aa90 100644 (file)
--- a/poll.c
+++ b/poll.c
@@ -199,13 +199,9 @@ poll_dispatch(struct event_base *base, void *arg, struct timeval *tv)
                        continue;
 
                if (r_ev && (res & r_ev->ev_events)) {
-                       if (!(r_ev->ev_events & EV_PERSIST))
-                               event_del(r_ev);
                        event_active(r_ev, res & r_ev->ev_events, 1);
                }
                if (w_ev && w_ev != r_ev && (res & w_ev->ev_events)) {
-                       if (!(w_ev->ev_events & EV_PERSIST))
-                               event_del(w_ev);
                        event_active(w_ev, res & w_ev->ev_events, 1);
                }
        }
index a21ee4ec192ccc870f20db46d92178fbab2bc3e8..92c3ed316a026c33953bf0961d32deacc97bb9ff 100644 (file)
--- a/select.c
+++ b/select.c
@@ -196,13 +196,9 @@ select_dispatch(struct event_base *base, void *arg, struct timeval *tv)
                        res |= EV_WRITE;
                }
                if (r_ev && (res & r_ev->ev_events)) {
-                       if (!(r_ev->ev_events & EV_PERSIST))
-                               event_del(r_ev);
                        event_active(r_ev, res & r_ev->ev_events, 1);
                }
                if (w_ev && w_ev != r_ev && (res & w_ev->ev_events)) {
-                       if (!(w_ev->ev_events & EV_PERSIST))
-                               event_del(w_ev);
                        event_active(w_ev, res & w_ev->ev_events, 1);
                }
        }