Skip to content

Commit 90452c8

Browse files
committed
Only return events from ppoll that were requested.
If the underlying system's select() returns bits that were not in the request set, our ppoll() implementation can return revents for events not requested, which can apparently cause a hang. Only return revents for activity in the requested event set. bz#3416, analysis and fix by yaroslav.kuzmin at vmssoftware com, ok djm@
1 parent 6c49eb5 commit 90452c8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

openbsd-compat/bsd-poll.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *tmoutp,
9191
fds[i].revents = 0;
9292
if (fd == -1)
9393
continue;
94-
if (FD_ISSET(fd, readfds))
94+
if ((fds[i].events & POLLIN) && FD_ISSET(fd, readfds))
9595
fds[i].revents |= POLLIN;
96-
if (FD_ISSET(fd, writefds))
96+
if ((fds[i].events & POLLOUT) && FD_ISSET(fd, writefds))
9797
fds[i].revents |= POLLOUT;
98-
if (FD_ISSET(fd, exceptfds))
98+
if ((fds[i].events & POLLPRI) && FD_ISSET(fd, exceptfds))
9999
fds[i].revents |= POLLPRI;
100100
}
101101

0 commit comments

Comments
 (0)