summaryrefslogtreecommitdiffstats
path: root/sys/kern/sys_socket.c
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2013-09-28 15:21:55 +0000
committermillert <millert@openbsd.org>2013-09-28 15:21:55 +0000
commit54beff47b69a9978611dfbe9f827c01d91357417 (patch)
tree29f86dd1f7d2bb67bbc73c614dd9b93b884f4aa5 /sys/kern/sys_socket.c
parentA few missing config_suspend(, DVACT_POWERDOWN) constructs after (diff)
downloadwireguard-openbsd-54beff47b69a9978611dfbe9f827c01d91357417.tar.xz
wireguard-openbsd-54beff47b69a9978611dfbe9f827c01d91357417.zip
poll(2) on a socket should set POLLHUP on EOF. This makes the
behavior of socketpair(2) match that of pipe(2) when the other end is closed. OK guenther@
Diffstat (limited to 'sys/kern/sys_socket.c')
-rw-r--r--sys/kern/sys_socket.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sys/kern/sys_socket.c b/sys/kern/sys_socket.c
index 9958e1f50cd..67fb49c4ea4 100644
--- a/sys/kern/sys_socket.c
+++ b/sys/kern/sys_socket.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys_socket.c,v 1.16 2013/04/05 08:25:30 tedu Exp $ */
+/* $OpenBSD: sys_socket.c,v 1.17 2013/09/28 15:21:55 millert Exp $ */
/* $NetBSD: sys_socket.c,v 1.13 1995/08/12 23:59:09 mycroft Exp $ */
/*
@@ -139,7 +139,10 @@ soo_poll(struct file *fp, int events, struct proc *p)
if (soreadable(so))
revents |= events & (POLLIN | POLLRDNORM);
}
- if (events & (POLLOUT | POLLWRNORM)) {
+ /* NOTE: POLLHUP and POLLOUT/POLLWRNORM are mutually exclusive */
+ if (so->so_state & SS_ISDISCONNECTED) {
+ revents |= POLLHUP;
+ } else if (events & (POLLOUT | POLLWRNORM)) {
if (sowriteable(so))
revents |= events & (POLLOUT | POLLWRNORM);
}