summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2014-08-05 20:37:44 +0930
committerRusty Russell <rusty@rustcorp.com.au>2014-08-05 20:37:44 +0930
commit31df8231a077488a9f4010a8863ca38993aa69c8 (patch)
tree72357ffef5c90eb1aae39188a6f4b113c717335a
parent0fbc79090f9ff5bc1caf8c0f0f05525a05f2e82d (diff)
ccan/io: use shutdown() before close.
During a debugging session, I wondered why poll() wasn't exiting when I killed a (local) peer. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
-rw-r--r--ccan/io/poll.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/ccan/io/poll.c b/ccan/io/poll.c
index 078de140..8f77dd42 100644
--- a/ccan/io/poll.c
+++ b/ccan/io/poll.c
@@ -78,6 +78,12 @@ static void del_fd(struct fd *fd)
}
num_fds--;
fd->backend_info = -1;
+
+ /* Closing a local socket doesn't wake poll() because other end
+ * has them open. See 2.6. When should I use shutdown()?
+ * in http://www.faqs.org/faqs/unix-faq/socket/ */
+ shutdown(fd->fd, SHUT_RDWR);
+
close(fd->fd);
}