HomeFreeBSD

Fix spurious ENOTCONN from closed unix domain socket other' side.

Description

Fix spurious ENOTCONN from closed unix domain socket other' side.

Sometimes, when doing read(2) over unix domain socket, for which the
other side socket was closed, read(2) returns -1/ENOTCONN instead of
EOF AKA zero-size read. This is because soreceive_generic() does not
lock socket when testing the so_state SS_ISCONNECTED|SS_ISCONNECTING
flags. It could end up that we do not observe so->so_rcv.sb_state bit
SBS_CANTRCVMORE, and then miss SS_ flags.

Change the test to check that the socket was never connected before
returning ENOTCONN, by adding all state bits for connected.

Reported and tested by: pho
In collaboration with: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D24819

Details

Provenance
kibAuthored on
Differential Revision
D24819: Fix spurious ENOTCONN from closed unix domain socket other' side.
Parents
rS361036: inetd(8): Add comments to all examples
Branches
Unknown
Tags
Unknown