mirror of
https://github.com/PowerShell/openssh-portable.git
synced 2025-07-26 23:34:55 +02:00
fix edge case in poll(2) wrapper
Correct handling of select(2) exceptfds. These should only be consulted for POLLPRI flagged pfds and not unconditionally converted to POLLERR. with and ok dtucker@
This commit is contained in:
parent
976b9588b4
commit
a1d42a6ce0
@ -33,8 +33,8 @@
|
|||||||
/*
|
/*
|
||||||
* A minimal implementation of ppoll(2), built on top of pselect(2).
|
* A minimal implementation of ppoll(2), built on top of pselect(2).
|
||||||
*
|
*
|
||||||
* Only supports POLLIN and POLLOUT flags in pfd.events, and POLLIN, POLLOUT
|
* Only supports POLLIN, POLLOUT and POLLPRI flags in pfd.events and
|
||||||
* and POLLERR flags in revents.
|
* revents. Notably POLLERR, POLLHUP and POLLNVAL are not supported.
|
||||||
*
|
*
|
||||||
* Supports pfd.fd = -1 meaning "unused" although it's not standard.
|
* Supports pfd.fd = -1 meaning "unused" although it's not standard.
|
||||||
*/
|
*/
|
||||||
@ -71,14 +71,12 @@ ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *tmoutp,
|
|||||||
fd = fds[i].fd;
|
fd = fds[i].fd;
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
continue;
|
continue;
|
||||||
if (fds[i].events & POLLIN) {
|
if (fds[i].events & POLLIN)
|
||||||
FD_SET(fd, readfds);
|
FD_SET(fd, readfds);
|
||||||
FD_SET(fd, exceptfds);
|
if (fds[i].events & POLLOUT)
|
||||||
}
|
|
||||||
if (fds[i].events & POLLOUT) {
|
|
||||||
FD_SET(fd, writefds);
|
FD_SET(fd, writefds);
|
||||||
|
if (fds[i].events & POLLPRI)
|
||||||
FD_SET(fd, exceptfds);
|
FD_SET(fd, exceptfds);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = pselect(maxfd + 1, readfds, writefds, exceptfds, tmoutp, sigmask);
|
ret = pselect(maxfd + 1, readfds, writefds, exceptfds, tmoutp, sigmask);
|
||||||
@ -90,15 +88,12 @@ ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *tmoutp,
|
|||||||
fds[i].revents = 0;
|
fds[i].revents = 0;
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
continue;
|
continue;
|
||||||
if (FD_ISSET(fd, readfds)) {
|
if (FD_ISSET(fd, readfds))
|
||||||
fds[i].revents |= POLLIN;
|
fds[i].revents |= POLLIN;
|
||||||
}
|
if (FD_ISSET(fd, writefds))
|
||||||
if (FD_ISSET(fd, writefds)) {
|
|
||||||
fds[i].revents |= POLLOUT;
|
fds[i].revents |= POLLOUT;
|
||||||
}
|
if (FD_ISSET(fd, exceptfds))
|
||||||
if (FD_ISSET(fd, exceptfds)) {
|
fds[i].revents |= POLLPRI;
|
||||||
fds[i].revents |= POLLERR;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user