Transfer proxy tunnel socket ownership - #247
Open
samuel-williams-shopify wants to merge 4 commits into
Open
Conversation
Assisted-By: devx/618580b0-d55f-4c2e-95b6-87e648f60543
Assisted-By: devx/618580b0-d55f-4c2e-95b6-87e648f60543
Assisted-By: devx/618580b0-d55f-4c2e-95b6-87e648f60543
Assisted-By: devx/618580b0-d55f-4c2e-95b6-87e648f60543
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.
Summary
Async::HTTP::Body::Pipe#to_ioa documented, one-shot transfer of the tail socketProxy#connect, with no callback or reference into its originating Async contextProxy#connectis used with a blockto_iocall fails explicitly and that closure from another thread is observed through the socket pairProxy#connectreturns an IO which may outlive or leave the thread or execution context that created it. Calling back into the pipe fromSocket#closewould therefore share mutable Async state across contexts, and Ruby IO autoclose does not invoke a Ruby-levelcloseoverride.Body::Pipe#to_ionow transfers ownership and clears the pipe reference to the returned socket. It may only be called once; subsequent calls raiseIOError. The caller exclusively owns that IO, so it can close normally or be automatically collected. The forwarding tasks observe EOF and write failures through the Unix socket pair and close their respective HTTP bodies. Cleanup is consequently eventual rather than an unsafe synchronous callback into the originating task.The block form retains deterministic scoped cleanup because the proxy still owns both values for the duration of the block.
This complements #244: transient CONNECT tasks do not keep the creator alive, while the returned socket is not retained by those tasks.
Verification
bundle exec sus test/async/http/body/pipe.rb test/async/http/proxy.rb(34 passed)bundle exec bake test(259 passed, 3 skipped)bundle exec rubocop(135 files, no offenses)COVERAGE=PartialSummary BUNDLE_WITH=maintenance bundle exec bake decode:index:coverage lib(293/293)