ccan/io: handle errors on poll()
authorRusty Russell <rusty@rustcorp.com.au>
Mon, 14 Oct 2013 11:02:58 +0000 (21:32 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 14 Oct 2013 11:02:58 +0000 (21:32 +1030)
Without this, closing an fd results in a spin...

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ccan/io/poll.c

index 06e3b59104d0f4e4d9d010e86109f31d59af7c04..42ed67ad278a0c870c9c4a98baa015eb0ed4e60a 100644 (file)
@@ -338,7 +338,7 @@ void *io_loop(void)
                                /* debug can recurse; anything can change. */
                                if (doing_debug())
                                        break;
                                /* debug can recurse; anything can change. */
                                if (doing_debug())
                                        break;
-                       } else if (events & POLLHUP) {
+                       } else if (events & (POLLHUP|POLLNVAL|POLLERR)) {
                                r--;
                                set_current(c);
                                set_plan(c, io_close());
                                r--;
                                set_current(c);
                                set_plan(c, io_close());