Opened 3 years ago
Closed 3 years ago
#17714 closed bug (fixed)
poll/select reports a listening socket as writable
Reported by: | selfish | Owned by: | axeld |
---|---|---|---|
Priority: | normal | Milestone: | R1/beta4 |
Component: | Network & Internet/Stack | Version: | R1/beta3 |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Platform: | All |
Description
Listening on a socket, then passing it to poll() with POLLOUT reports it as writable, despite actually doing so being an error (and unlike other platforms). See attached source file for an example.
Attachments (1)
Change History (5)
by , 3 years ago
comment:2 by , 3 years ago
I think the B_SELECT_ERROR check should probably account for read and write errors too? Or maybe we need to do something different for LISTEN sockets? Either way I don't think flipping the check is correct, but perhaps PulkoMandy or korli know more here.
comment:3 by , 3 years ago
Had a look at FreeBSD, and they simply don't notify anything for POLLOUT on listening sockets. https://review.haiku-os.org/c/haiku/+/5247
comment:4 by , 3 years ago
Milestone: | Unscheduled → R1/beta4 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Change merged in hrev56062.
The problem seems to be that socket_request_notification sends a notification when socket_send_avail() < B_OK, but TCPEndpoint::SendAvailable (which eventually gets called for socket_send_avail for TCP sockets) returns EPIPE (which is < B_OK) for cases in which the socket is not writable. The impression I get is that it meant to check for > B_OK since the same TCP method returns the (positive) free buffer size for a writable socket, for example. Flipping the check does indeed solve the issue, if this seems reasonable I'd like to submit a patch.