Fix Windows MSG_PEEK and MSG_WAITALL receive handling #797
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!797
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/797/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@theantipopau on GitHub · 2026-09-24 05:59 UTC · original
theantipopau:windows-peek-waitall→main· +352 −18 · 2 files · 8 commits · closed without mergingProblem
On Windows, a guest
recv/recvfromthat combinesMSG_PEEK | MSG_WAITALLfailsoutright. Winsock rejects the pair with
WSAEOPNOTSUPP(10045) on stream sockets,datagram sockets, non-blocking sockets, at end of file and for zero-length requests,
so any title that uses this (very common) way of waiting for a complete message sees an
error instead of data. The existing regression test for it
(
tests/KernelFileSystemTests.cpp::CheckSocketWakeup) could not even be built afterthe SDL3 migration, because
SDL3/SDL_main.hrenamesmaintoSDL_mainand thetarget links as a console app.
Changes
tests/KernelFileSystemTests.cpp— defineSDL_MAIN_HANDLEDbefore the SDL includesso the test provides its own entry point and links on Windows again.
src/libs/network.cpp— on Windows only, intercept theMSG_PEEK | MSG_WAITALLcombination in
Recvfromand reproduce the guest (FreeBSD) behaviour:them, so a following receive still sees the whole message;
0atend of file);
MSG_DONTWAITand non-blocking sockets return what is buffered, orEWOULDBLOCKwhen nothing is, without waiting;MSG_WAITALL, as on FreeBSD;0immediately (Winsock otherwise blocks).POSIX keeps the existing
recv/recvfrombehaviour; the only change there is thatthe call is factored into a small
RecvHosthelper.Why the wait is paced instead of polled
MSG_PEEKdoes not consume, so a partially delivered message keeps the socketreadable:
WSAPoll(POLLRDNORM)returns in 0 ms in that state and a select/poll loopwould spin. The implementation therefore sleeps 1 ms between peeks and uses the poll
only to observe
POLLHUP/POLLERR/POLLNVAL, i.e. the "stop waiting" signal. Ablocking guest call still blocks exactly as long as the data takes, and the fast path
(no data missing) performs a single
recv(MSG_PEEK)with no sleeping at all.The guest non-blocking mode is tracked in
SocketTransportbecauseioctlsocket(FIONBIO)can only set the mode, never report it.Testing
Built with the documented Windows toolchain (clang-cl + Ninja, Release) and verified
locally on Windows 11 / Ryzen 7 9800X3D / Radeon RX 9070 XT (driver 26.8.1):
kernel_file_system_testspasses, 15/15 consecutive runs, including new coverage forfragmented delivery, bytes surviving a peek, zero-length receive,
MSG_DONTWAIT,a non-blocking socket and end-of-file short reads;
ctest: 22/40 pass. The 17 failures are the pre-existing local Vulkan limitation(
production rasterization features are not supported— this driver does not exposeVK_EXT_attachment_feedback_loop_dynamic_state), andsave_data_memoryis reported"Not Run" because its target is not part of the
kyty_testsaggregate; both areunrelated to this change.
Risk
Low and Windows-only. Previously the intercepted combination always failed, so blocking
callers now block as the guest expects, with at most 1 ms of extra latency for a
trailing fragment. Non-blocking and
MSG_DONTWAITcallers return immediately. The2 MiB-scale P2P logical sockets are rejected before this path and are unaffected.
@coderabbitai[bot] on GitHub · 2026-09-24 06:13 UTC · original · edited 2026-10-02 23:53 UTC
Navigate logical layers of code changes, visualize relationships, and explore their blast radius.
📝 Walkthrough
Walkthrough
Windows socket transports now track guest nonblocking mode, including on accepted sockets. Receive dispatch uses shared host receive logic, with a Windows-specific path for
MSG_PEEK | MSG_WAITALL. Socket tests cover fragmented data, zero-length receives, nonblocking behavior, peer closure, accepted sockets, and datagram peeks. P2P socket acceptance now returnsEOPNOTSUPP.Priority: ⬇️ Low
Change: Bug fix
Merge Risk: 🔵 Low · up to
c834bA peer reset during a fragmented receive can return an error instead of the buffered bytes. This is a narrow remaining issue; the accepted-socket and datagram fixes appear ready.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands.@ -866,0 +867,4 @@#if defined(_WIN32)// Winsock cannot report the current mode, so the guest blocking mode is tracked here.std::atomic_bool nonblocking {false};#endif@coderabbitai[bot] on GitHub · 2026-09-24 06:13 UTC · original
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 3993
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 42172
🌐 Web query:
Microsoft Winsock accept FIONBIO nonblocking mode accepted socket inheritance official documentation💡 Result:
<source_evidence>
https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-accept layout: Conceptual ... title: accept ... (winsock2.h) - Win3 ... canonicalUrl: https://learn.microsoft ... com/en-us/windows/win32/ ... /winsock2/nf-wins ... breadcrumb_path ... UID: NF:wins ... The accept function permits an incoming ... attempt on a socket. ... The **accept** function permits an incoming connection attempt on a socket. ## Syntax ```cpp SOCKET WSAAPI accept( [in] SOCKET s, [out] sockaddr *addr, [in, out] int *addrlen ); ``` ## Parameters `[in] s` A descriptor that identifies a socket that has been placed in a listening state with the listen function. The connection is actually made with the socket that is returned by **accept**. `[out] addr` An optional pointer to a buffer that receives the address of the connecting entity, as known to the communications layer. The exact format of the *addr* parameter is determined by the address family that was established when the socket from the sockaddr structure was created. `[in, out] addrlen` An optional pointer to an integer that contains the length of structure pointed to by the *addr* parameter. ## Return value If no error occurs, **accept** returns a value of type **SOCKET** that is a descriptor for the new socket. This returned value is a handle for the socket on which the actual connection is made. Otherwise, a value of **INVALID\_SOCKET** is returned, and a specific error code can be retrieved by calling WSAGetLastError. The integer referred to by *addrlen* initially contains the amount of space pointed to by *addr*. On return it will contain the actual length in bytes of the address returned. | Error code | Meaning | | --- | --- | | - **WSANOTINITIALISED** | A successful WSAStartup call must occur before using this function. | | - **WSAECONNRESET** | An incoming connection was indicated, but was subsequently terminated by the remote peer prior to accepting the call. | | - **WSAEFAULT** | The *addrlen* parameter is too small or *addr* is not a valid part of the user address space. | ... | - ** ... SAEINTR ... | A blocking Windows Sockets 1.1 call was canceled through WSACancelBlockingCall. ... prior to accept ... | - **WSAEMFILE** | The queue is nonempty upon entry to accept and there are no descriptors available. | | - **WSAENETDOWN** | The network subsystem has failed. | | - **WSAENOBUFS** | No buffer space is available. | | - **WSAENOTSOCK** | The descriptor is not a socket. | | - **WSAEOPNOTSUPP** | The referenced socket is not a type that supports connection-oriented service. | | - **WSAEWOULDBLOCK** | The socket is marked as nonblocking and no connections are present to be accepted. | ## Remarks The **accept** function extracts the first connection on the queue of pending connections on socket *s*. It then creates and returns a handle to the new socket. The newly created socket is the socket that will handle the actual connection; it has the same properties as socket *s*, including the asynchronous events registered with the WSAAsyncSelect or WSAEventSelect functions. The **accept** function can block the caller until a connection is present if no pending connections are present on the queue, and the socket is marked as blocking. If the socket is marked as nonblocking and no pending connections are present on the queue, **accept** returns an error as described in the following. After the successful completion of **accept** returns a new socket handle, the accepted socket cannot be used to accept more connections. The original socket remains open and listens for new connection requests. The parameter *addr* is a result parameter that is filled in with the address of the connecting entity, as known to the communications layer. The exact format of the *addr* parameter is determined by the address family in which the communication is occurring. The *addrlen* is a value-result parameter; it should initially contain the amount of space pointed to by *addr*; on return it will contain the actual length (in bytes) of the address returned. The **accept** function... https://learn.microsoft.com/en-us/windows/win32/winsock/winsock-ioctls ### FIONBIO ... Enable or disable non-blocking mode on socket s. The lpvInBuffer parameter points at an unsigned long (QoS), which is nonzero if non-blocking mode is to be enabled and zero if it is to be disabled. When a socket is created, it operates in blocking mode (that is, non-blocking mode is disabled). This is consistent with BSD sockets. ... The WSAAsyncSelect or WSAEventSelect routine automatically sets a socket to non-blocking mode. If WSAAsyncSelect or WSAEventSelect has been issued on a socket, then any attempt to use WSAIoctl to set the socket back to blocking mode will fail with WSAEINVAL. To set the socket back to blocking mode, an application must first disable WSAAsyncSelect by calling WSAAsyncSelect with the lEvent parameter equal to zero, or disable WSAEventSelect by calling WSAEventSelect with the lNetworkEvents parameter equal to zero. https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsaaccept # WSAAccept function (winsock2.h) - Win32 apps | Microsoft Learn ... The WSAAccept function conditionally accepts a connection based on the return value of a condition function, provides quality of service flow specifications, and allows the transfer of connection data. ... | - WSAEWOULDBLOCK | A non-blocking socket operation could not be completed immediately. This error is returned if the socket is marked as nonblocking and no connections are present to be accepted. | ... The WSAAccept function extracts the first connection on the queue of pending connections on socket s, and checks it against the condition function, provided the condition function is specified (that is, not NULL). If the condition function returns CF_ACCEPT, WSAAccept creates a new socket. The newly created socket has the same properties as socket s including asynchronous events registered with WSAAsyncSelect or with WSAEventSelect. If the condition function returns CF_REJECT, WSAAccept rejects the connection request. The condition function runs in the same thread as this function does, and should return as soon as possible. If the decision cannot be made immediately, the condition function should return CF_DEFER to indicate that no decision has been made, and no action about this connection request should be taken by the service provider. When the application is ready to take action on the connection request, it will invoke WSAAccept again and return either CF_ACCEPT or CF_REJECT as a return value from the condition function. ... A socket in default mode (blocking) will block until a connection is present when an application calls WSAAccept and no connections are pending on the queue. ... A socket in nonblocking mode (blocking) fails with the error WSAEWOULDBLOCK when an application calls WSAAccept and no connections are pending on the queue. After WSAAccept succeeds and returns a new socket handle, the accepted socket cannot be used to accept any more connections. The original socket remains open and listens for new connection requests. ... The g parameter is assigned within the condition function to indicate any of the following actions: ... - If g is an existing socket group identifier, add s to this group, provided all the requirements set by this group are met. - If g = SG_UNCONSTRAINED_GROUP, create an unconstrained socket group and have s as the first member. - If g = SG_CONSTRAINED_GROUP, create a constrained socket group and have s as the first member. - If g = zero, no group operation is performed. ... For unconstrained ... , any set of sockets can be grouped together ... supported by a ... service provider. ... connection-oriented sockets, ... connections on all grouped sockets be to the same address on ... same host. For newly ... groups, the new group identifier can be retrieved by using getsock ... parameter set to SOL_SOCKET and the optname parameter set ... _ID. A ... remain valid until the last socket ... to this socket group is closed. ... IDs are unique across all processes for a given ... provider. A ... remain valid until the last socket belonging to this socket group is closed. Socket group identifiers are unique across all processes for a given service provider. For more information on socket groups, see ... Remarks for the WSASocket functions. ... Note To protect use of the WSAAccept function from SYN attacks, applications must perform full TCP handshakes (SYN-SYNACK-ACK) before reporting the connection request. Protecting against SYN attacks in this manner results in the SO_CONDITIONAL_ACCEPT socket option becoming inoperative; the conditional function is still called, and the WSAAccept function operates properly, but server applications that rely on clients being unable to perform the handshake will not operate properly. Note When issuing a blocking Winsock call such as WSAAccept, Winsock may need to wait for a network event before the call can complete. Winsock performs an alertable wait in this situation, which can be interru... https://learn.microsoft.com/en-us/windows/win32/api/mswsock/nf-mswsock-acceptex The **AcceptEx** function accepts a new connection, returns the local and remote address, and receives the first block of data sent by the client application. **Note** This function is a Microsoft-specific extension to the Windows Sockets specification. ## Syntax ```cpp BOOL AcceptEx( ... [in] SOCKET sListenSocket, [in] SOCKET sAcceptSocket ... [in] PVOID lpOutputBuffer, [in] DWORD dwReceiveDataLength, ... [in] DWORD dwLocalAddressLength, [in] DWORD dwRemoteAddressLength, ... [out] LPDWORD lpdwBytesReceived, [in] LPOVERLAPPED lpOverlapped ); ... ## Parameters `[in] sListenSocket` ... A descriptor identifying a socket that has already been called with ... connect on this socket ... `[in] sAcceptSocket` ... A descriptor identifying a socket on which to accept ... . This socket must not be bound or connected. ... `[in] lpOutput ... ## Return value If no error occurs, the **AcceptEx** function completed successfully and a value of **TRUE** is returned. If the function fails, **AcceptEx** returns **FALSE**. The WSAGetLastError function can then be called to return extended error information. If **WSAGetLastError** returns **ERROR\_IO ... PENDING**, then the operation was successfully initiated and is still in progress. If the error is WSAECONNRESET, an incoming connection was indicated, but was subsequently terminated by the remote peer prior to accepting the call. ## Remarks The **AcceptEx** function combines several socket functions into a single API/kernel transition. The **AcceptEx** function, when successful, performs three tasks: - A new connection is accepted. - Both the local and remote addresses for the connection are returned. - The first block of data sent by the remote is received. **Note** The function pointer for the **AcceptEx** function must be obtained at run time by making a call to the WSAIoctl function with the **SIO\_GET\_EXTENSION\_FUNCTION\_POINTER** opcode specified. The input buffer passed to the **WSAIoctl** function must contain **WSAID\_ACCEPTEX**, a globally unique identifier (GUID) whose value identifies the **AcceptEx** extension function. On success, the output returned by the **WSAIoctl** function contains a pointer to the **AcceptEx** function. The **WSAID\_ACCEPTEX** GUID is defined in the *Mswsock.h* header file. A program can make a connection to a socket more quickly using **AcceptEx** instead of the accept function. A single output buffer receives the data, the local socket address (the server), and the remote socket address (the client). Using a single buffer improves performance. When using **AcceptEx**, the GetAcceptExSockaddrs function must be called to parse the buffer into its three distinct parts (data, local socket address, and remote socket address). On Windows XP and later, once the **AcceptEx** function completes and the **SO\_UPDATE\_ACCEPT\_CONTEXT** option is set on the accepted socket, the local address associated with the accepted socket can also be retrieved using the getsockname function. Likewise, the remote address associated with the accepted socket can be retrieved using the getpeername function. The buffer size for the local and remote address must be 16 bytes more than the size of the sockaddr structure for the transport protocol in use because the addresses are written in an internal format. For example, the size of a **sockaddr\_in** (the address structure for TCP/IP) is 16 bytes. Therefore, a buffer size of at least 32 bytes must be specified for the local and remote addresses. The **AcceptEx** function uses overlapped I/O, unlike the accept function. If your application uses **AcceptEx**, it can service a large number of clients with a relatively small number of threads. As with all overlapped Windows functions, either Windows events or completion ports can be used as a completion notification mechanism. Another key difference between the **AcceptEx** function and the accept function is that **AcceptEx** requires the caller to already have two sockets: - One that... https://learn.microsoft.com/en-us/windows/win32/winsock/winsock-socket-state-notifications tcpAcceptSocket = accept(serverContext->listenerSocket, NULL, NULL); if (tcpAcceptSocket == INVALID_SOCKET) { errorCode = GetLastError(); goto Exit; } if (ioctlsocket(tcpAcceptSocket, FIONBIO, &nonBlocking) != 0) { errorCode = GetLastError(); goto Exit; } ... // Register the accepted connection. registration.completionKey = (PVOID)tcpAcceptSocket; registration.eventFilter = SOCK_NOTIFY_REGISTER_EVENT_IN | SOCK_NOTIFY_REGISTER_EVENT_HANGUP; registration.operation = SOCK_NOTIFY_OP_ENABLE; registration.triggerFlags = SOCK_NOTIFY_TRIGGER_LEVEL; registration.socket = tcpAcceptSocket; errorCode = ProcessSocketNotifications(serverContext->ioCompletionPort, 1, ®istration, 0, 0, NULL, NULL); // Make sure all registrations were processed. if (errorCode != ERROR_SUCCESS) { goto Exit; } ... // Make sure each registration was successful. ... if (registration.registration ... SUCCESS) { errorCode = registration.registrationResult; goto ... // Use non-blocking sockets with edge-triggered notifications, since the data must be // drained before a rising edge can be observed again. errorCode = ioctlsocket(serverSocket, FIONBIO, &nonBlocking); if (errorCode != ERROR_SUCCESS) { goto Exit; } ... SOCKET_CONTEXT ... socketContextOut) { DWORD errorCode; ... SOCKET_CONTEXT ... NULL; ... socketContext = ... SOCKET_CONTEXT*)malloc(sizeof(*socketContext)); if (socketContext == NULL) { errorCode = ERROR_NOT_ ... OUGH_MEMORY; goto Exit; ... } ... ZeroMemory(socketContext, sizeof(*socketContext)); socketContext->socketType = SOCKET_TYPE ... ACCEPT; socketContext->socket = accept(listenSocket, NULL, NULL); ... if (socketContext->socket == INVALID_SOCKET) { errorCode ... goto Exit ... *socketContextOut = socketContext; ... socketContext = NULL ... ThreadRoutine(_In ... CONTEXT* server ... Context; HANDLE io ... Port; ... registrations: one to re-enable the listening ... // notification, and one to register the newly- ... . SOCK_NOTIFY_REGISTRATION registrationBuffer[SERVER_DEQUEUE_COUNT * 2]; UINT32 registrationCount; SOCK_NOTIFY_REGISTRATION* registration; OVERLAPPED_ENTRY notifications[SERVER_DEQUEUE_COUNT]; UINT32 notificationCount; UINT32 events; SOCKET_CONTEXT* ... Context; SOCKET_CONTEXT* acceptedContext; BOOLEAN shouldExit; CHAR dataBuffer[512]; ... // Process the socket notification, taking socket-specific actions. switch (socketContext->socketType) { case SOCKET_TYPE_LISTENER: // Accepting connections in response to notifications implicitly throttles // the rate at which incoming connections are accepted, and limits scale-out for // new connection acceptance. Consider using AcceptEx if greater scaling of //connection acceptance is desired. // Perform an accept regardless of the notification. The only possible notifications // are for available connections or error conditions. Any possible error conditions // will be processed as part of the accept. errorCode = AcceptConnection(socketContext->socket, &acceptedContext); if (errorCode == ERROR_SUCCESS) { // Register the accepted connection. registration = ®istrationBuffer[registrationCount]; registration->socket = acceptedContext->socket; registration->completionKey = acceptedContext; registration->eventFilter = SOCK_NOTIFY_EVENT_IN | SOCK_NOTIFY_EVENT_HANGUP; registration->operation = SOCK_NOTIFY_OP_ENABLE; registration->triggerFlags = SOCK_NOTIFY_TRIGGER_ONESHOT | SOCK_NOTIFY_TRIGGER_LEVEL; registrationCount += 1; } // Re-arm the existing listening socket registration. registration = ®istrationBuffer[registrationCount]; registration->socket = socketContext->socket; registration->completionKey = socketContext; registration->eventFilter = SOCK_NOTIFY_EVENT_IN; registration->operation = SOCK_NOTIFY_OP_ENABLE; registration->triggerFlags = SOCK_NOTIFY_TRIGGER_ONESHOT | SOCK_NOTIFY_TRIGGER_LEVEL; registrationCount += 1; break; ... case SOCKET_TYPE_ACCEPT: // The registration was removed. Clean up the contex…[truncated]Citations:
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 7744
Copy the listener mode to the accepted transport.
Winsock preserves the listener's
FIONBIOmode on the socket returned byaccept, butSocketTransport(accepted)initializesnonblockingtofalse.RecvPeekWaitAllthen treats the accepted socket as blocking and can wait indefinitely for the remaining bytes of a partialMSG_WAITALLreceive.🐛 Suggested fix in
Accept@ -1097,0 +1181,4 @@return host_len;}return SetHostSocketError();}@coderabbitai[bot] on GitHub · 2026-09-24 06:13 UTC · original · edited 2026-09-26 01:43 UTC
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Datagram peeks fail with EMSGSIZE instead of returning truncated data.
Winsock fails a datagram
recv/recvfromwith WSAEMSGSIZE when the buffer is smaller than the datagram. It still fills the buffer.Recvfrom(Lines 2315-2318) turns this case into success withhost_len.RecvPeekWaitAllhandles every negative result withSetHostSocketError(). Line 2304 then returns -1, so the guest getsPOSIX_EMSGSIZE. FreeBSD returns the truncated length.Zero-length receives with a source address hit this every time. Line 1132 sends the datagram case to
RecvHostwith length 0. A non-empty datagram then fails with WSAEMSGSIZE. The comment at Line 1134 says this case should report the source address.🐛 Proposed fix
📝 Committable suggestion
@ -1097,0 +1194,4 @@// Preserve the already-buffered prefix instead of turning it into WSAECONNRESET.return peeked;}}@coderabbitai[bot] on GitHub · 2026-09-24 06:13 UTC · original · edited 2026-09-24 08:48 UTC
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 8140
Bound the blocking peek without removing fragmented-read waiting.
A short
MSG_PEEK | MSG_WAITALLresult is expected while the remaining fragment can still arrive. Returning that result immediately would break the fragmented-data contract: the test sends a short prefix, delays the remainder, and expects the receive to return the complete message.The current non-consuming retry can still wait indefinitely when the prefix fills the receive window. Keep waiting for fragments, but add a bounded wait or another capacity-independent termination condition. Do not use
SO_RCVBUFas an exact receive-window limit; Windows may auto-tune the effective TCP receive window.✅ Addressed in commit
3727d67@coderabbitai[bot] on GitHub · 2026-09-24 06:13 UTC · original · reviewed
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
6228e009-5411-425f-831d-1ff2809729f3📥 Commits
Reviewing files that changed from the base of the PR and between
3dc3fd0197anddcc2de2468.📒 Files selected for processing (2)
src/libs/network.cpptests/KernelFileSystemTests.cppIncluded review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
@theantipopau on GitHub · 2026-09-24 08:42 UTC · original
Updated the head to include the validated follow-up commit and current upstream/main.
Addressed the review findings:
Validation after the upstream merge:
The local AMD Vulkan harness limitation remains separate: production rasterization tests cannot start without VK_EXT_attachment_feedback_loop_dynamic_state.
@coderabbitai[bot] on GitHub · 2026-09-24 08:45 UTC · original · edited 2026-09-24 08:48 UTC
On
tests/KernelFileSystemTests.cppline 569 (outdated):🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Avoid a scheduling-dependent failure in the accepted-socket test.
If the async worker starts late or runs slowly,
wait_for(250ms)can time out even whenNet::Recvcorrectly returns the prefix before the suffix is sent. The test then fails becausereturned_before_completionis false. Use a more generous deadline, and keep the suffix send as the fallback that releases a blocking receive. (eel.is)✅ Addressed in commit
3727d67@coderabbitai[bot] on GitHub · 2026-09-24 08:45 UTC · original · reviewed
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
98e983b5-7a5d-40cc-b363-2f79252bd9ad📥 Commits
Reviewing files that changed from the base of the PR and between
dcc2de2468andb5dab67f1d.📒 Files selected for processing (2)
src/libs/network.cpptests/KernelFileSystemTests.cppIncluded review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
@theantipopau on GitHub · 2026-09-24 08:54 UTC · original
The final review pass is clean. The accepted-socket path now reads the listener transport state, applies the matching FIONBIO mode to the accepted Winsock handle, and records it for later PEEK/WAITALL calls; the regression covers a partial prefix. The datagram path handles WSAEMSGSIZE inside the helper and uses a scratch byte for zero-length source-address peeks; the regression covers both the peek and consume. The blocking WAITALL path intentionally has no arbitrary timeout because FreeBSD permits a blocking WAITALL receive to wait for the remaining fragment; the existing delayed-fragment test protects that contract. The accepted-socket synchronization window is now two seconds to avoid CI scheduling flakes.
@francoisatt on GitHub · 2026-09-24 18:38 UTC · original
Tested
3727d67on Windows with an NVIDIA GPU (RTX 5080, driver 596.49, clang-cl + Ninja, full clean build), merge-base02578f3.Full ctest: 40/40, no failures.
That covers the 17 Vulkan-backed tests your local AMD harness cannot start (no VK_EXT_attachment_feedback_loop_dynamic_state), plus kernel_file_system, which passes here. save_data_memory also passes once its target is built explicitly, which is what your #798 addresses.
One coordination note: this overlaps with #751 (rudy-07), opened three days earlier — same Winsock MSG_PEEK | MSG_WAITALL limitation, same SDL_MAIN_HANDLED fix. I tested that one on Windows as the reporter of #505: it makes kernel_file_system pass too, and I verified the failure is real by building main with only its SDL change (0xc0000409, "guest PEEK and WAITALL preserve the wake bytes"). Yours is the broader implementation (accepted sockets, datagrams, MSG_DONTWAIT, EOF) and addresses the partial-arrival case Copilot raised there. Neither PR references the other, so flagging it here and on #751 so a maintainer can pick one rather than leaving both open.
Not verified: any behaviour in an actual title, and non-Windows platforms.
@coderabbitai[bot] on GitHub · 2026-09-24 21:07 UTC · original · reviewed
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
d65a9171-05eb-44fb-96c6-dbb00e72379e📥 Commits
Reviewing files that changed from the base of the PR and between
3727d67269and f98551db039f75fe082371552bead0bd1f24683b.📒 Files selected for processing (2)
src/libs/network.cpptests/KernelFileSystemTests.cppIncluded review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
@ -763,0 +806,4 @@deadline.data()) == 1,"non-waiting peek bytes are readable");Check(Net::Recv(reader, message.data(), message.size(), 0xc2) == prefix_length,"guest MSG_DONTWAIT PEEK and WAITALL returns the buffered prefix");@coderabbitai[bot] on GitHub · 2026-09-24 21:07 UTC · original · edited 2026-09-24 22:03 UTC
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Wait for readiness before the non-waiting peeks.
Line 489 sends
prefix_lengthbytes and then callsNet::Recvwith0xc2(MSG_DONTWAIT | MSG_WAITALL | MSG_PEEK) at once. Line 502 does the same thing on the guest non-blocking socket. Neither call waits for the bytes to arrive. If loopback delivery is late,Net::Recvreturns-1withEWOULDBLOCKandCheckaborts the test.TCP_NODELAYcontrols when the sender transmits. It does not guarantee that the bytes are already in the receive buffer.Before each non-waiting peek, wait for the reader to become readable with
Net::Selectand a deadline. This is the same pattern as lines 450-454. The peek still checks the non-waiting behavior because 5 bytes are buffered and 8 are requested.Proposed fix
Also applies to: 500-503
✅ Addressed in commit c834baf
@coderabbitai[bot] on GitHub · 2026-09-24 22:08 UTC · original · reviewed
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
f0c98059-6845-49b8-a82c-f4c506882e52📥 Commits
Reviewing files that changed from the base of the PR and between f98551db039f75fe082371552bead0bd1f24683b and c834baf88dbf9ef6033859ec0841fa090218048e.
📒 Files selected for processing (1)
tests/KernelFileSystemTests.cpp🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
@ -1097,0 +1181,4 @@return host_len;}return SetHostSocketError();}@theantipopau on GitHub · 2026-09-26 01:43 UTC · original
This was already addressed before your review ran, in
52315508(Preserve accepted socket modes and datagram peeks). The head now has:so a truncated datagram reports the copied length rather than surfacing
POSIX_EMSGSIZEto the guest. The zero-length-with-source-address case you flagged takes the one-bytescratchpath first, and Winsock copying that byte without error is covered byreturn host_len == 0 ? 0 : peekedon the line below.Also pushed in
33e8e343:WaitForPeekedBytesno longer treatsPOLLNVALas terminal, and a terminal event now returns the already-buffered prefix rather than falling through to aWSAECONNRESETon the next peek.@ -1097,0 +1181,4 @@return host_len;}return SetHostSocketError();}@coderabbitai[bot] on GitHub · 2026-09-26 01:43 UTC · original
🧩 Analysis chain
🏁 Script executed:
Length of output: 7935
@theantipopau, I need to correct my earlier reply. The shell check succeeded. Atc834baf,RecvPeekWaitAllhandlesWSAEMSGSIZEand uses the one-byte scratch buffer for zero-length datagram peeks with a source address. My finding was already invalid at that revision, so I withdraw it.The checked revision still includes
POLLNVALinWaitForPeekedBytes. This check does not verify the later33e8e343change.✅ Review thread resolved.
You are interacting with an AI system.
@theantipopau on GitHub · 2026-09-27 13:04 UTC · original
Merged current
upstream/main(through025b39c0). One thing worth flagging foranyone else carrying a branch that touches
CheckSocketWakeup:#851added anet_recv(..., MSG_WAITALL)consume of the five wake bytes, andthis branch already consumed those same five bytes with
Net::Recv(..., MSG_WAITALL). Both survived the merge, so the second blockingreceive waited for bytes the first had already taken — the test hung instead of
failing, which is the worst shape for CI. The
#797commit already fixed thisclass of failure once (
f133b246, half-close the writer so a short sendsurfaces as a short read rather than a spin); this was the same hazard from the
consumer side.
Resolution, same on both PRs:
errno-preserving checks, drop the duplicate direct consume, and re-cover the
direct
Net::RecvguestMSG_WAITALLpath on a freshly sent whole message;end-of-file block closes the writer once, then upstream's errno-preserving EOF
check and its reader close end the function.
kernel_file_system_testsbuilds and passes 3x in a row on the merged result onWindows/clang-cl.
@theantipopau on GitHub · 2026-09-30 22:10 UTC · original
Evidence: upstream
mainfails this test on Windows, this branch passes itWhile chasing #867 (which reports
kernel_file_system_tests.exenever being built), I built thetarget at plain
upstream/mainb7a1fac8and ran it. One sub-test fails on Windows today:That is the
MSG_PEEK | MSG_WAITALL(0x42) case inCheckSocketWakeup.Net::Recvdoes nottranslate the Windows flags, so the peeked read does not return the payload the test sent.
Building and running the same target at this branch's head (
2b158c179):Three consecutive clean runs, so this is not a flake being papered over — upstream
mainisdeterministically red here and this branch is deterministically green.
Two things worth noting for reviewers:
.github/workflows/build.ymlbuilds andctests onlyaudio_out2_port_tests,ime_dialog_testsandvirtual_memory_allocation_tests;kernel_file_system_testsisEXCLUDE_FROM_ALLand is not in the-Rfilter, so the failureis invisible to the workflow.
main).I split that out into #948 rather than stacking it here, so this PR stays reviewable on its own.
Not asking for anything beyond a look — happy to rebase onto
mainif that helps.@theantipopau on GitHub · 2026-10-02 23:55 UTC · original
Rebased onto current upstream/main (
e317465d)Two conflicts were resolved by keeping both sides:
SetsockoptSO_NBIO (upstream restructured this in #954): the merged code keeps upstream's cross-platform#if defined(_WIN32)/fcntlshape and layers this PR's Windows-only tracking of the guest blocking mode on top (state.transport->nonblocking), which Winsock cannot query.CheckSocketWakeup: upstream's newer error-path checks (EBADF/EFAULT/EOPNOTSUPP and the Linux SIGPIPE block) now run first, then this PR's EOF-tail checks (partial message at close, repeated peeks, EOF), then upstream's errno-preserving EOF check and the reader close. Each check runs exactly once.Testing (Windows,
kernel_file_system_tests)RC=0, KernelFileSystemTests: all cases passed.Relation to #981 (same bug, different mechanism)
#981 fixes the same Winsock
MSG_PEEK | MSG_WAITALLrejection by introducing a per-transport receive queue that everyRecvfromdrains (plusSelect/EpollWaitchanges). This PR instead keeps the kernel socket buffer as the single copy of received data:recv(MSG_PEEK)is paced by poll for the WAITALL length, so a buffered prefix never desynchronizes from what other readers of the socket see;MSG_DONTWAITmaps to a readiness poll, zero-length andWSAEMSGSIZEdatagram peeks are handled explicitly, and a peer that closes mid-wait returns the buffered prefix instead ofWSAECONNRESET;Because there is no second queue, there is no drift risk with paths that read the socket outside
Recvfrom(P2P framing, epoll, other threads), and this PR also covers cases #981 does not: datagram peek edge cases, P2P accept, accepted-socket mode preservation, and the blocking WAITALL short-send hang.If a queued-emulation layer is ever wanted, it can be layered on top of this later — but with the Winsock rejection handled here, the regression cases do not need it.
@Nmzik on GitHub · 2026-10-03 17:16 UTC · original
Credited
Pull request closed