Repository navigation
THRIFT-6117: Reject duplicate opens in Ruby SSL and UNIX sockets - #4195
Merged
Merged
Conversation
Client: rb Thrift::SSLSocket and Thrift::UNIXSocket override Socket#open without its already-open check, so a second open connected again and replaced the handle. The first connection stayed open but unreachable, and a later close closed only the replacement. Both now raise TransportException::ALREADY_OPEN before connecting, as Socket#open does, and keep the existing connection. In UNIXSocket the check sits outside the rescue that turns connect errors into NOT_OPEN. A shared example opens a real TCP, SSL and UNIX connection, opens it again, and checks that the second open is rejected, that the server sees no new connection, and that close ends the original one. Generated-By: amp/0.0.1794916837-g564d50 (model: anthropic/claude-opus-5-5; operator: kpumuk@apache.org)
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.
Thrift::SSLSocketandThrift::UNIXSocketoverrideSocket#openwithout the already-open check added in THRIFT-6112. A secondopenon either transport connected again and replaced the handle, leaving the first connection open but unreachable; a latercloseclosed only the replacement. Both now raiseTransportException::ALREADY_OPENbefore connecting, asThrift::Socketdoes, and keep the existing connection. InUNIXSocketthe check sits outside the rescue that reports connect errors asNOT_OPEN.A shared example now opens a real TCP, SSL and UNIX-domain connection, opens it again, and checks that the second open is rejected, the handle is unchanged, the server sees no new connection, and
closeends the original one. The UNIX and SSL cases fail on master and pass with this change; the existing TCP-only example moved into the shared example.Reproduction
ruby -I lib/rb/lib repro.rbwith Ruby 4.0.9 on master (50242d7):With this change: