]> granicus.if.org Git - libevent/commitdiff
r16454@catbus: nickm | 2007-11-06 09:59:45 -0500
authorNick Mathewson <nickm@torproject.org>
Tue, 6 Nov 2007 20:57:32 +0000 (20:57 +0000)
committerNick Mathewson <nickm@torproject.org>
Tue, 6 Nov 2007 20:57:32 +0000 (20:57 +0000)
 Small code cleanups in epoll_dispatch(): remove a needless variable and some redundant conditionals.

svn:r478

ChangeLog
epoll.c

index 4e4f6ada161a03af23c8ad7a934ca703adbd660f..ea7c712ef8050713945168f1ff64daa8061e6e93 100644 (file)
--- 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 8c0d3e31dcf2fde5d1892f9c49fd0061431731e4..37b09eb94fb9ac1d9e420697a9160d9039af1ad7 100644 (file)
--- 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)