summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorjtl <jtl@FreeBSD.org>2018-05-12 01:55:24 +0000
committerjtl <jtl@FreeBSD.org>2018-05-12 01:55:24 +0000
commit7176fc304b485041df5f10bbece36867d8e7b6d0 (patch)
tree4161b2cd39b7d806cfde448f6503b66689e3eb65 /sys/kern
parentf9ed7c59c6531dc7c4be7f1fcddb036ea0c401d1 (diff)
downloadFreeBSD-src-7176fc304b485041df5f10bbece36867d8e7b6d0.zip
FreeBSD-src-7176fc304b485041df5f10bbece36867d8e7b6d0.tar.gz
r285910 attempted to make shutdown() be POSIX compliant by returning
ENOTCONN when shutdown() is called on unconnected sockets. This change was slightly modified by r316874, which returns ENOTCONN in the case of an unconnected datagram socket, but still runs the shutdown code for the socket. This specifically supports the case where the user-space code is using the shutdown() call to wakeup another thread blocked on the socket. In PR 227259, a user is reporting that they have code which is using shutdown() to wakup another thread blocked on a stream listen socket. This code is failing, while it used to work on FreeBSD 10 and still works on Linux. It seems reasonable to add another exception to support something users are actually doing, which used to work on FreeBSD 10, and still works on Linux. And, it seems like it should be acceptable to POSIX, as we still return ENOTCONN. This is a direct commit to stable/11. The listen socket code changed substantially in head, and the code change there will be substantially more complex. In the meantime, it seems to make sense to commit this trivial fix to stable/11 given the fact that users appear to depend on this behavior, this appears to have been an unintended change in stable/11, and we did not announce the change. PR: 227259 Reviewed by: ed Approved by: re (gjb) Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D15021 Tested by: Eric Masson (emss at free.fr)
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/uipc_socket.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 15ca984..1caa290 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -2359,7 +2359,8 @@ soshutdown(struct socket *so, int how)
* both backward-compatibility and POSIX requirements by forcing
* ENOTCONN but still asking protocol to perform pru_shutdown().
*/
- if (so->so_type != SOCK_DGRAM)
+ if (so->so_type != SOCK_DGRAM &&
+ !(so->so_options & SO_ACCEPTCONN))
return (ENOTCONN);
soerror_enotconn = 1;
}
OpenPOWER on IntegriCloud