Files
AnyPS5/docs/dev/debt/changes/fix-libkernel-recvmsg-zero-length-stream.md
CocoandClaude Opus 5.5 14bebd06fc fix(libkernel): answer a zero-length recvmsg on a stream socket as recv does
recv and recvfrom answer a zero-length receive on a stream socket
without the host: 0 when it is connected, ENOTCONN when it is not, as
FreeBSD 11.4's soreceive_generic does when nothing is queued. recvmsg
asked the host instead, after waiting for the socket to be readable, so
on an empty connected socket it failed with EAGAIN under MSG_DONTWAIT or
a non-blocking socket and blocked otherwise, and an unconnected socket
did not get ENOTCONN. recvmsg now takes the same answer before waiting,
except on a Unix stream socket with a control buffer, where FreeBSD
delivers queued control messages and the host still answers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 19:33:29 +05:30

904 B

libkernel

change [recv and recvfrom]

  • recv, recvfrom and recvmsg (libkernel) answer some cases without the host. A zero-length receive on a stream socket returns 0, or ENOTCONN when it is not connected (L1566-L1578), as on a PS5 (firmware 13.60). On an empty datagram socket it returns 0 at once; the console was measured only with MSG_DONTWAIT, and the blocking case follows FreeBSD 11.4's soreceive_dgram, which returns 0 before waiting. A zero-length recvmsg on a Unix stream socket with a control buffer still asks the host, as FreeBSD then delivers queued control messages, and the answers ignore a pending socket error, which FreeBSD returns first. A datagram another thread takes after the check makes a zero-length receive wait