eloop_pollts(struct pollfd * fds, nfds_t nfds,
const struct timespec *ts, const sigset_t *sigmask)
{
- fd_set read_fds;
+ fd_set read_fds, write_fds;
nfds_t n;
int maxfd, r;
FD_ZERO(&read_fds);
+ FD_ZERO(&write_fds);
maxfd = 0;
for (n = 0; n < nfds; n++) {
if (fds[n].events & POLLIN) {
if (fds[n].fd > maxfd)
maxfd = fds[n].fd;
}
+ if (fds[n].events & POLLOUT) {
+ FD_SET(fds[n].fd, &write_fds);
+ if (fds[n].fd > maxfd)
+ maxfd = fds[n].fd;
+ }
}
- r = pselect(maxfd + 1, &read_fds, NULL, NULL, ts, sigmask);
+ r = pselect(maxfd + 1, &read_fds, &write_fds, NULL, ts, sigmask);
if (r > 0) {
for (n = 0; n < nfds; n++) {
fds[n].revents =
FD_ISSET(fds[n].fd, &read_fds) ? POLLIN : 0;
+ if (FD_ISSET(fds[n].fd, &write_fds))
+ fds[n].revents |= POLLOUT;
}
}