HomeFreeBSD

r285910 attempted to make shutdown() be POSIX compliant by returning

Description

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)