Repository navigation
Accept one connection at a time on a Windows listener, so a paused one delivers in arrival order (#305) - #307
Merged
Merged
Conversation
…e delivers in arrival order (#305)
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Follow-up to #306. libuv keeps completed AcceptEx requests in a LIFO stack (
win/tcp.cpushes at :1234, pops at :738). A paused listener that holds several delivers the newest first; #306 switched to single accept at the firststop(), but libuv finishes that switch only after all 32 pre-posted requests are consumed, so every pause until then could reorder. On the server's Windows CI (PR true-async/server#360)h1/064failed this way: a keep-alive connection overtook an older one, which waited past its 5 s.Now
uv_tcp_simultaneous_accepts(h, 0)is set before the firstuv_listenof every Windows TCP listener, andstop()no longer switches. A paused listener holds at most one connection; the rest wait in the kernel backlog in arrival order, and worker threads sharing one socket get an even share (libuv's docs name uneven load as the cost of simultaneous accepts). Cost: one accept per loop iteration on Windows, not measured. Ruling by the Sage over three options (a php-async FIFO queue was rejected: more code, and it keeps up to 32 accepted connections per paused worker).Evidence: the server's Windows CI on #360 builds this branch through a temporary
PHP_ASYNC_BRANCH;h1/064there is the proof. Linux: a no-op, asynctest 5 of 5.