Repository navigation
Fix two Linux net bugs that stalled Elixir's Mix: fresh UDP sockets, and a missed epoll rearm - #361
Merged
Merged
Conversation
…TCONN
A datagram conversation has no host socket until it binds to a port,
connects, or sends. Until then ipready answered with the default (ready
to read and write) and recvfrom with ENOTCONN, so a poll on a fresh UDP
socket said it was readable and the read failed. Erlang's resolver
polls its new UDP socket and logged the ENOTCONN as an error
({udp_error, Port, enotconn}) during Mix's Hex fetches. Now it's
writable only and a nonblocking recv is EAGAIN, as on Linux, and
creating the host socket kicks the watchers, so a recv blocked before
the socket existed wakes for the reply to its first sendto.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LLcnT1EGgD3xQKfCsAjjvA
… a rearm isn't missed An epoll_ctl in another thread changes the interest list and then moves the readiness generation (pollWake). epoll_wait copied the list and only then took the generation, from its first poll, so an EPOLL_CTL_MOD that rearmed an EPOLLONESHOT entry between the two was counted in the generation the wait slept on while the copy still had the entry disarmed: the wait slept with the fd ready until something else woke it. Erlang's poll thread waits that way while its schedulers rearm each socket after a read, so a TLS download stopped partway and Mix's Hex fetches timed out after 60 seconds, in about one run in three. The generation is now taken before the copy. The new epoll_rearm case reads loopback connections a segment at a time, rearming after each, and failed 3 of 3 runs before (a connection readable with no event) and passes 3 of 3 after. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LLcnT1EGgD3xQKfCsAjjvA
Owner
Author
|
Test results on 38a7be5, in a cloud container on the sud engine (no KVM there):
Still unchecked: KVM, HVF, and WHP, and the 9front cases, since this container has no 9front root. Windows has its own hostsock (hostsock-win32.c), which this doesn't change, but the epoll and UDP code is shared. Generated by Claude Code |
This was referenced Nov 28, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Jeff · project thread
Found running real-world programs through h9x on the sud engine:
mix local.hex(Elixir 1.15, OTP 26, aselixir-plug/plugbuilds) timed out after 60 seconds in about one run in three, where it takes 4 seconds natively. Bug fixes, so no proposal.EPOLL_CTL_MODthat rearmed a oneshot entry. It copied the interest list and only then took the readiness generation it sleeps on, so a rearm from another thread between the two was counted in that generation while the copy still had the entry disarmed. The wait slept with the fd ready until something else woke it. Erlang's poll thread waits this way while its schedulers rearm each socket after a read, so a TLS download stopped partway. The generation is now taken before the copy.ENOTCONN. A datagram conversation has no host socket until it binds to a port, connects, or sends, and until thenipreadygave the default (readable and writable) andrecvfromgaveENOTCONN. Erlang's resolver logged{udp_error, Port, enotconn}. It's now writable only, a nonblocking recv isEAGAIN, and creating the host socket kicks the watchers, so a recv that blocked before it existed wakes for the reply.New
[linux-net]cases:epoll_rearm(loopback connections read a segment at a time with a rearm after each, as Erlang's TLS does) andudp_fresh.spec/abi-linux.mdsays both.Generated by Claude Code