Skip to content

soc_getsockopt: report the pending error for SO_ERROR - #611

Closed
Migushthe2nd wants to merge 2 commits into
devkitPro:masterfrom
Migushthe2nd:fix/soc-so-error
Closed

Migushthe2nd wants to merge 2 commits into
devkitPro:masterfrom
Migushthe2nd:fix/soc-so-error

Conversation

@Migushthe2nd

@Migushthe2nd Migushthe2nd commented Oct 13, 2026 •

Copy link
Copy Markdown

LLM-generated content removed

Migush added 2 commits October 13, 2026 22:34
The SOC service doesn't wake a poll() waiting for POLLOUT when a
non-blocking connect() completes, so poll() only returns once its
timeout runs out (curl waits a second per new connection this way). It
also reports a refused connection only as readable, so a POLLOUT waiter
never learns about it.

Wait for POLLOUT in 10 ms slices, and watch those sockets for POLLIN
too: POLLIN without POLLOUT on a socket that then fails to receive is a
failed connection, reported as POLLERR | POLLHUP. Nothing tells a socket
that is still connecting from a connected one (getpeername() succeeds
for both), so connected sockets waiting for POLLOUT are sliced as well.
Waits for POLLIN alone are unchanged.

Fixes the poll() part of devkitPro#412.
For SO_ERROR the service returns the result code of an earlier
operation on the socket, in its own codes, instead of the socket's
pending error: -26 (EINPROGRESS) after a non-blocking connect(), even
once it has completed. Convert the code, and for the ones that aren't
errors of the socket itself (EINPROGRESS, EALREADY, ENOTCONN, EAGAIN)
report whether its connection failed instead: 0, or the reason
(ECONNREFUSED for a refused connection).

Fixes the SO_ERROR part of devkitPro#412.
@fincs fincs closed this Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants