fix(network): bsdsocket event monitor and blocking-call fixes - #2334
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 111289851d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- bsdthr_blockingstuff: keep EINTR when a blocking call was aborted via sockabort; the unconditional saved_errno restore reported EAGAIN/EINPROGRESS so callers retried aborted operations - event monitor: treat unconnected datagram sockets as ready for read/write readiness polling (getpeername fails with ENOTCONN on bound UDP sockets, which blocked all event delivery) - event monitor: recv() returning 0 is EOF only on stream sockets; on UDP it is a valid zero-length datagram and must not fire REP_CLOSE
1112898 to
fadcaa1
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fadcaa1a45
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Marking unconnected datagram sockets connected=true let the monitor's REP_CONNECT fallback post a false connect-completed event when a broad mask (e.g. REP_ALL) included REP_CONNECT. dgram now relaxes only the read/write readiness gates; connected keeps the getpeername() result.
trap_put_string() writes through the terminating NUL and ignores its maxlen on the direct-memory path, so a hostname longer than the caller's buffer spilled past the validated namelen range into adjacent guest memory. Truncate to namelen-1 plus NUL and copy with the strictly bounded trap_put_bytes().
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f91940f5c1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
REP_CLOSE polling added datagram sockets to readfds, but a queued datagram keeps select() readable forever with no event able to fire (REP_CLOSE never fires on datagrams, REP_READ not requested or already fired) — a permanent 10ms busy-poll. Datagram sockets have no EOF; their readfds entry comes from the REP_READ gate, so close-only polling is now stream-only.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f3720a198d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…RITE on datagrams - REP_ACCEPT fired for any readable socket whose mask contained it (e.g. REP_ALL), sending datagram and connected sockets down an invalid accept path. accept-ready is now tracked via SO_ACCEPTCONN at registration and both the readfds gate and the event handler require it — this also stops the spurious REP_ACCEPT a connected TCP socket with REP_ALL previously got on incoming data. - host_setsockopt force-adds REP_WRITE to REP_CONNECT requests (dynAMIte implicit-writability workaround). On an unconnected datagram socket that forced bit fired an unrequested write notification; the force is now stream-only.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b67567688d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
REP_ACCEPT gating snapshots SO_ACCEPTCONN at registration, so a server arming SO_EVENTMASK before listen() never reported accept-ready: host_listen() now updates the monitor entry on success, and listen-before-mask orderings query live state at registration anyway.
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
Fixes three bsdsocket.library host-layer bugs found by an automated review of the amiberry-lite backport PR (BlitterStudio/amiberry-lite#39). All three exist in current master.
bsdthr_blockingstuff: EINTR lost on aborted blocking calls. When a blocking send/recv/accept/connect is aborted viasockabort, the code setserrno = EINTR, but the unconditionalerrno = saved_errnoat function exit overwrites it with the pre-selectEAGAIN/EINPROGRESS.bsdlib_threadfunc()then maps the wrong errno to the Amiga side, so callers retry an operation that was explicitly interrupted.register_socket_events()derivesconnectedfromgetpeername(), which fails withENOTCONNon bound-but-unconnected UDP sockets. The monitor gates REP_READ/REP_WRITE/REP_CLOSE polling onconnected, so a UDP server usingSO_EVENTMASKnever receives read notifications. Datagrams are now detected viaSO_TYPEand treated as always ready for readiness polling.peek_socket()mapsrecv() == 0to EOF. On a connected UDP socket a zero-length datagram is valid data, but it was reported as REP_CLOSE. EOF semantics are now applied to stream sockets only.Verification
socket_emu=true: no errors, clean exit on SIGTERM