]> git.ozlabs.org Git - ccan/blobdiff - ccan/io/poll.c
io: don't fail if we get a signal.
[ccan] / ccan / io / poll.c
index a4e83ed761e77251767b01b3e3f5c5dd3492bfcd..b005a97e4b1d07879a4e281a8d48276baaac2fa1 100644 (file)
@@ -130,9 +130,11 @@ void backend_new_plan(struct io_conn *conn)
                num_waiting--;
 
        pfd->events = 0;
-       if (conn->plan[IO_IN].status == IO_POLLING)
+       if (conn->plan[IO_IN].status == IO_POLLING_NOTSTARTED
+           || conn->plan[IO_IN].status == IO_POLLING_STARTED)
                pfd->events |= POLLIN;
-       if (conn->plan[IO_OUT].status == IO_POLLING)
+       if (conn->plan[IO_OUT].status == IO_POLLING_NOTSTARTED
+           || conn->plan[IO_OUT].status == IO_POLLING_STARTED)
                pfd->events |= POLLOUT;
 
        if (pfd->events) {
@@ -278,8 +280,13 @@ void *io_loop(struct timers *timers, struct timer **expired)
                }
 
                r = pollfn(pollfds, num_fds, ms_timeout);
-               if (r < 0)
+               if (r < 0) {
+                       /* Signals shouldn't break us, unless they set
+                        * io_loop_return. */
+                       if (errno == EINTR)
+                               continue;
                        break;
+               }
 
                for (i = 0; i < num_fds && !io_loop_return; i++) {
                        struct io_conn *c = (void *)fds[i];