Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Jun 2024 05:55:08 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 279871] recv(2) on tcp socket with O_NONBLOCK returns 0 after connection reset
Message-ID:  <bug-279871-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D279871

            Bug ID: 279871
           Summary: recv(2) on tcp socket with O_NONBLOCK returns 0 after
                    connection reset
           Product: Base System
           Version: 14.0-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: richard@annexi-strayline.com

I am observing that when invoking recv(2) on a TCP socket (taken from
listen(2)), where O_NONBLOCK is set, and the remote peer closes the connect=
ion,
recv continues to return 0 forever.

The recv(2) man page says:

"If no messages are available at the socket, the receive call waits for a
message to arrive, unless the socket is non-blocking (see fcntl(2)) in which
case the value -1 is returned and the global variable errno is set to EAGAI=
N."

It seems in this case we would expect -1 + EAGAIN for a non-blocking socket
where the connection has been reset.

This was tested with a small program reading from a socket that was written=
 to
via telnet from localhost. Each call to recv is given a 3-byte buffer.

I am not sure when this behavior began..

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-279871-227>