]> granicus.if.org Git - libevent/commitdiff
fixes to handle error cases by Anatoly Vorobey at pobox.com
authorNiels Provos <provos@gmail.com>
Sat, 25 Oct 2003 21:58:33 +0000 (21:58 +0000)
committerNiels Provos <provos@gmail.com>
Sat, 25 Oct 2003 21:58:33 +0000 (21:58 +0000)
svn:r90

epoll.c
poll.c

diff --git a/epoll.c b/epoll.c
index edca74ce8e86cc742e989f8c79a4dd6407691d98..a3a35f33a77eed6ffc059a3cfcec0bcdb2426c9a 100644 (file)
--- a/epoll.c
+++ b/epoll.c
@@ -195,11 +195,17 @@ epoll_dispatch(void *arg, struct timeval *tv)
        LOG_DBG((LOG_MISC, 80, "%s: epoll_wait reports %d", __func__, res));
 
        for (i = 0; i < res; i++) {
-               int which = 0, what;
+               int which = 0;
+               int what = events[i].events;
                struct event *evread = NULL, *evwrite = NULL;
 
                evep = (struct evepoll *)events[i].data.ptr;
-               what = events[i].events;
+   
+                if (what & EPOLLHUP)
+                        what |= EPOLLIN | EPOLLOUT;
+                else if (what & EPOLLERR)
+                        what |= EPOLLIN | EPOLLOUT;
+
                if (what & EPOLLIN) {
                        evread = evep->evread;
                        which |= EV_READ;
diff --git a/poll.c b/poll.c
index b6613ba91ffd17c5403be1534ee455f18c133723..773e4d1b672fbd72d9581080554e1c9bd94a2134 100644 (file)
--- a/poll.c
+++ b/poll.c
@@ -189,13 +189,18 @@ poll_dispatch(void *arg, struct timeval *tv)
                return (0);
 
        for (i = 0; i < nfds; i++) {
+                int what = pop->event_set[i].revents;
+               
                res = 0;
+
                /* If the file gets closed notify */
-               if (pop->event_set[i].revents & POLLHUP)
-                       pop->event_set[i].revents = POLLIN|POLLOUT;
-               if (pop->event_set[i].revents & POLLIN)
+               if (what & POLLHUP)
+                       what |= POLLIN|POLLOUT;
+                if (what & POLLERR) 
+                        what |= POLLIN|POLLOUT;
+               if (what & POLLIN)
                        res |= EV_READ;
-               if (pop->event_set[i].revents & POLLOUT)
+               if (what & POLLOUT)
                        res |= EV_WRITE;
                if (res == 0)
                        continue;