Opened 2 years ago

Closed 2 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)

socket.c (960 bytes ) - added by selfish 2 years ago.

Download all attachments as: .zip

Change History (5)

by selfish, 2 years ago

Attachment: socket.c added

comment:1 by selfish, 2 years ago

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 myself.

Last edited 2 years ago by selfish (previous) (diff)

comment:2 by waddlesplash, 2 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 korli, 2 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

Last edited 2 years ago by korli (previous) (diff)

comment:4 by waddlesplash, 2 years ago

Milestone: UnscheduledR1/beta4
Resolution: fixed
Status: newclosed

Change merged in hrev56062.

Note: See TracTickets for help on using tickets.