Date: Sat, 12 May 2018 01:55:24 +0000 (UTC) From: "Jonathan T. Looney" <jtl@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r333511 - stable/11/sys/kern Message-ID: <201805120155.w4C1tOoD013170@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jtl Date: Sat May 12 01:55:24 2018 New Revision: 333511 URL: https://svnweb.freebsd.org/changeset/base/333511 Log: 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) Modified: stable/11/sys/kern/uipc_socket.c Modified: stable/11/sys/kern/uipc_socket.c ============================================================================== --- stable/11/sys/kern/uipc_socket.c Sat May 12 01:43:32 2018 (r333510) +++ stable/11/sys/kern/uipc_socket.c Sat May 12 01:55:24 2018 (r333511) @@ -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; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201805120155.w4C1tOoD013170>