libkernel: poll on Windows reports a stream whose peer closed as POLLHUP only, never as POLLIN #8482

Closed
opened 2026-10-20 13:27:43 +00:00 by xXPBSXx · 0 comments
xXPBSXx commented 2026-10-20 13:27:43 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-20T13:27:43Z.


Repro

Windows host. Connected stream pair; one side calls shutdown(s, SHUT_WR) (or close); the other calls poll({fd, POLLIN}, 1, 1000).
Expected (FreeBSD 11.4 sopoll_generic, sys/kern/uipc_socket.c:3080-3086): revents == POLLIN. A socket that can receive no more is readable; POLLHUP is added only when it can send no more either.
Actual: revents == POLLHUP (0x10) with POLLIN requested alone, 0x14 with POLLIN|POLLOUT: WSAPoll reports POLLHUP without POLLRDNORM, and poll_nid_postfix passes it on. A caller that waits for POLLIN and then reads the end of the stream never wakes for it.
Test: core/libs/tests/GuestPoll.cpp (PollsAStreamWhosePeerClosed, new; aborts before the fix).
Fix branch: https://github.com/xXPBSXx/AnyPS5/tree/fix/poll-peer-close-pollin
AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5942518557 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/8482). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-20T13:27:43Z. --- ### Repro Windows host. Connected stream pair; one side calls `shutdown(s, SHUT_WR)` (or `close`); the other calls `poll({fd, POLLIN}, 1, 1000)`. Expected (FreeBSD 11.4 `sopoll_generic`, sys/kern/uipc_socket.c:3080-3086): `revents == POLLIN`. A socket that can receive no more is readable; `POLLHUP` is added only when it can send no more either. Actual: `revents == POLLHUP` (0x10) with `POLLIN` requested alone, `0x14` with `POLLIN|POLLOUT`: `WSAPoll` reports `POLLHUP` without `POLLRDNORM`, and `poll_nid_postfix` passes it on. A caller that waits for `POLLIN` and then reads the end of the stream never wakes for it. Test: `core/libs/tests/GuestPoll.cpp` (`PollsAStreamWhosePeerClosed`, new; aborts before the fix). Fix branch: https://github.com/xXPBSXx/AnyPS5/tree/fix/poll-peer-close-pollin AI-assisted (Claude Code).
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#8482
No description provided.