fixes to handle error cases by Anatoly Vorobey at pobox.com

svn:r90
This commit is contained in:
Niels Provos 2003-10-25 21:58:33 +00:00
parent d780375fc4
commit e1cd86d73e
2 changed files with 17 additions and 6 deletions

10
epoll.c
View File

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

13
poll.c
View File

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