From e1cd86d73e9959f50fa24ac39dbb6cea9a14b386 Mon Sep 17 00:00:00 2001 From: Niels Provos Date: Sat, 25 Oct 2003 21:58:33 +0000 Subject: [PATCH] fixes to handle error cases by Anatoly Vorobey at pobox.com svn:r90 --- epoll.c | 10 ++++++++-- poll.c | 13 +++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/epoll.c b/epoll.c index edca74ce..a3a35f33 100644 --- 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 b6613ba9..773e4d1b 100644 --- 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; -- 2.40.0