Make the logic for active events work better with internal events; patch from Christopher Layne

svn:r509
This commit is contained in:
Niels Provos 2007-11-12 02:31:07 +00:00
parent bbed0954b1
commit 4a1a2e0d52
2 changed files with 5 additions and 17 deletions

View File

@ -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.

20
event.c
View File

@ -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;