Repository navigation
fix(libkernel): answer a receive after SHUT_RD or with no buffer without the host - #8492
Conversation
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
fogydes
left a comment
There was a problem hiding this comment.
Tested this change against current main.
Notes:
- Conventions check clean (
tools/check_conventions.py). - Built
guest_tcp_testsand ran CTest locally on Windows (MinGW-w64):1/1 Test #1534: guest_tcp ........................ Passed 0.09 sec 100% tests passed, 0 tests failed out of 1 - Verified the FreeBSD 11.4
soreceive_genericemulation matches expectations:- Bypassing the host for
socket.receiveShutavoids Winsock'sWSAESHUTDOWNreturningEPIPEto the guest, instead cleanly returning EOF (0). - Zero-length stream receive returns
0when connected (orENOTCONNwhen unconnected viagetpeername), avoiding Winsock's blocking behavior on 0-length reads. - In
recvfrom, correctly clears*addressLength = 0on answered receives where no sender address is produced.
- Bypassing the host for
|
On Linux (WSL2 Ubuntu 24.04, GCC 13.3, Release; not a bare-metal CI) |
|
Follow-up for the Linux failure reported above. The Checked: Linux (WSL2 Ubuntu 24.04, GCC 13.3, Release; not a bare-metal CI): |
…out the host soreceive_generic returns 0 for a socket whose receive side is shut and for a zero-length receive on a connected stream socket (ENOTCONN when it is not connected), without waiting. Winsock fails the first with WSAESHUTDOWN, which reached the guest as EPIPE, and blocks the second until data arrives. recv and recvfrom now answer both themselves. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
On Linux the host keeps data that was buffered before shutdown(SHUT_RD) and guest_socket_pair expects to read it, so the shortcut that answers 0 for any receive after SHUT_RD broke that test there. Limit the shortcut to Windows, where the host cannot answer it, and run the post-shutdown receives of guest_tcp on Windows only. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
643c064 to
32f8205
Compare
|
Checked the diff against FreeBSD 11.4 |
What
recvandrecvfromhanded every receive to the host. On Windows that fails a receive aftershutdown(SHUT_RD)withWSAESHUTDOWN(reported asEPIPE) and blocks a zero-length receive on a stream socket until data arrives. FreeBSD 11.4'ssoreceive_genericreturns 0 for a socket whose receive side is shut and for a zero-length receive on a connected stream socket (ENOTCONNwhen it is not connected), without waiting; TCP uses it in 11.4. Both calls now answer these cases themselves, before any wait.recvfromalso reports a zero address length.recvmsgis unchanged. The Technical debt entry says so.Fixes #8491
Overlap:
git merge-treehas conflicts with #7090 (one), #8448 (one) and #8474 (two) inUdp.cpp; the others (#8392, #8463, #8483, #7511, #7850, #7490, #8312) are clean. Whichever lands second rebases.pr_overlapwas not run.Tested
Windows 10 (19045), MinGW-w64 GCC 15.2.0, Release, on upstream/main cabd80f + this commit:
guest_tcp: the new case aborts without the change toUdp.cppand passes with it. It checks a zero-length receive on an unconnected socket (ENOTCONN) and on a connected one with and withoutMSG_DONTWAIT(0),recvfromreporting address length 0, andrecv/recvfromreturning 0 aftershutdown(SHUT_RD)even though the peer sent data.guest_datagram_recv,guest_sce_net,guest_socket_error,guest_socket_timeouts,guest_udp,guest_poll,guest_socket_pairandguest_recvmsg_memorypass.python tools/check_conventions.py --base upstream/main: passes.recvmsg.Checklist
main; no other open PR implements the same functions (fix(libkernel): report a stream whose peer closed as readable in poll on Windows #8483 and feat(libkernel): pass descriptors in SCM_RIGHTS messages on Unix sockets #7090 touchUdp.cppelsewhere).mdfiles or images added to the repositoryAI-assisted (Claude Code).
🤖 Generated with Claude Code