From 4a1a2e0d52a83a3b38f651a4480af3d8f7dcf435 Mon Sep 17 00:00:00 2001 From: Niels Provos Date: Mon, 12 Nov 2007 02:31:07 +0000 Subject: [PATCH] Make the logic for active events work better with internal events; patch from Christopher Layne svn:r509 --- ChangeLog | 2 +- event.c | 20 ++++---------------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 908b00af..68382680 100644 --- a/ChangeLog +++ b/ChangeLog @@ -48,4 +48,4 @@ Changes in current version: o Fix many build issues when using the Microsoft C compiler. o Remove a bash-ism in autogen.sh o When calling event_del on a signal, restore the signal handler's previous value rather than setting it to SIG_DFL. Patch from Christopher Layne. - + o Make the logic for active events work better with internal events; patch from Christopher Layne. diff --git a/event.c b/event.c index 82610c3b..f24b4748 100644 --- a/event.c +++ b/event.c @@ -829,23 +829,17 @@ timeout_process(struct event_base *base) void event_queue_remove(struct event_base *base, struct event *ev, int queue) { - int docount = 1; - if (!(ev->ev_flags & queue)) event_errx(1, "%s: %p(fd %d) not on queue %x", __func__, ev, ev->ev_fd, queue); - if (ev->ev_flags & EVLIST_INTERNAL) - docount = 0; - - if (docount) + if (~ev->ev_flags & EVLIST_INTERNAL) base->event_count--; ev->ev_flags &= ~queue; switch (queue) { case EVLIST_ACTIVE: - if (docount) - base->event_count_active--; + base->event_count_active--; TAILQ_REMOVE(base->activequeues[ev->ev_pri], ev, ev_active_next); break; @@ -866,8 +860,6 @@ event_queue_remove(struct event_base *base, struct event *ev, int queue) void event_queue_insert(struct event_base *base, struct event *ev, int queue) { - int docount = 1; - if (ev->ev_flags & queue) { /* Double insertion is possible for active events */ if (queue & EVLIST_ACTIVE) @@ -877,17 +869,13 @@ event_queue_insert(struct event_base *base, struct event *ev, int queue) ev, ev->ev_fd, queue); } - if (ev->ev_flags & EVLIST_INTERNAL) - docount = 0; - - if (docount) + if (~ev->ev_flags & EVLIST_INTERNAL) base->event_count++; ev->ev_flags |= queue; switch (queue) { case EVLIST_ACTIVE: - if (docount) - base->event_count_active++; + base->event_count_active++; TAILQ_INSERT_TAIL(base->activequeues[ev->ev_pri], ev,ev_active_next); break; -- 2.40.0