]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Add POLLOUT to the pselect wrapper.
authorRoy Marples <roy@marples.name>
Fri, 26 Feb 2016 16:04:12 +0000 (16:04 +0000)
committerRoy Marples <roy@marples.name>
Fri, 26 Feb 2016 16:04:12 +0000 (16:04 +0000)
eloop.c

diff --git a/eloop.c b/eloop.c
index d260d0ecff619f1db18b2cea5945f36c5f4e857c..1b429f1894f4bdc0c16fe1cd216e6728bb885089 100644 (file)
--- a/eloop.c
+++ b/eloop.c
@@ -208,11 +208,12 @@ static int
 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) {
@@ -220,13 +221,20 @@ eloop_pollts(struct pollfd * fds, nfds_t nfds,
                        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;
                }
        }