From d257a4c0d6527fff60bfa19f05b7937213375695 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 6 Nov 2007 20:57:32 +0000 Subject: [PATCH] r16454@catbus: nickm | 2007-11-06 09:59:45 -0500 Small code cleanups in epoll_dispatch(): remove a needless variable and some redundant conditionals. svn:r478 --- ChangeLog | 1 + epoll.c | 29 +++++++++++++---------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4e4f6ada..ea7c712e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -35,3 +35,4 @@ Changes in current version: o added two additional libraries: libevent_core and libevent_extra in addition to the regular libevent. libevent_core contains only the event core whereas libevent_extra contains dns, http and rpc support o Begin using libtool's library versioning support correctly. If we don't mess up, this will more or less guarantee binaries linked against old versions of libevent continue working when we make changes to libevent that do not break backward compatibility. o Fix evhttp.h compilation when TAILQ_ENTRY is not defined. + o Small code cleanups in epoll_dispatch(). diff --git a/epoll.c b/epoll.c index 8c0d3e31..37b09eb9 100644 --- a/epoll.c +++ b/epoll.c @@ -208,34 +208,31 @@ epoll_dispatch(struct event_base *base, void *arg, struct timeval *tv) event_debug(("%s: epoll_wait reports %d", __func__, res)); for (i = 0; i < res; i++) { - int which = 0; int what = events[i].events; struct event *evread = NULL, *evwrite = NULL; evep = (struct evepoll *)events[i].data.ptr; - - if (what & EPOLLHUP) - what |= EPOLLIN | EPOLLOUT; - else if (what & EPOLLERR) - what |= EPOLLIN | EPOLLOUT; - - if (what & EPOLLIN) { - evread = evep->evread; - which |= EV_READ; - } - if (what & EPOLLOUT) { - evwrite = evep->evwrite; - which |= EV_WRITE; + if (what & (EPOLLHUP|EPOLLERR)) { + evread = &evep->evread; + evwrite = &evep->evwrite; + } else { + if (what & EPOLLIN) { + evread = evep->evread; + } + + if (what & EPOLLOUT) { + evwrite = evep->evwrite; + } } - if (!which) + 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)) + !(evwrite->ev_events & EV_PERSIST)) event_del(evwrite); if (evread != NULL) -- 2.40.0