io: handle duplex corner cases.
[ccan] / ccan / io / poll.c
index 0078fc658411c1d50e01a5c3e9eed278f5214a83..1b11badd642c0d87d1270d642ac63db40f9cb24e 100644 (file)
@@ -346,7 +346,11 @@ void *do_io_loop(struct io_conn **ready)
                                                 * anything can change. */
                                                if (doing_debug())
                                                        break;
-                                               if (!(events&(POLLIN|POLLOUT)))
+
+                                               /* If no events, or it closed
+                                                * the duplex, continue. */
+                                               if (!(events&(POLLIN|POLLOUT))
+                                                   || !c->plan.next)
                                                        continue;
                                        }
                                }