Repository navigation
ssl: support SSLSocket#connect and #accept with timeout - #1098
Merged
Merged
Conversation
rhenium
force-pushed
the
ky/ssl-handshake-timeout
branch
from
September 2, 2026 12:48
76bc4f0 to
2cf80fe
Compare
Member
|
Do you default to |
rhenium
force-pushed
the
ky/ssl-handshake-timeout
branch
from
October 10, 2026 09:36
2cf80fe to
1efb173
Compare
Let the extension provide only the essential part to call the OpenSSL API: SSLSocket#ssl_connect, #ssl_accept, #ssl_read, and #ssl_write. Implement the public methods in ssl.rb: SSLSocket#connect, #accept, #sysread, and #syswrite, along with their #*_nonblock variants. This greatly simplifies code and prepares for the upcoming patches to add proper timeout support and closed-stream state tracking, which do not need to be in the extension.
Currently String.new(capacity: len) causes Hash allocations for the keyword arguments, which is undesirable in this hot path. This workaround should be reverted once it is no longer necessary.
Subtract elapsed time from the timeout before retrying
IO#wait_{read,writ}able.
Currently, each call to IO#wait_{read,writ}able (or rb_io_wait() before
the previous patch) uses the full default timeout. This makes
SSLSocket#timeout= ineffective when a peer splits a TLS record into
many small TCP segments and sends them slowly.
Buffered methods such as #gets still apply timeout separately to each
primitive blocking operation, but this appears to match the behavior of
core IO methods.
rhenium
force-pushed
the
ky/ssl-handshake-timeout
branch
from
October 11, 2026 05:48
1efb173 to
09f15f0
Compare
Add a keyword argument timeout to specify the total time allowed for the TLS handshake to complete. Inspired by Addrinfo#connect(timeout:) and TCPSocket.open(connect_timeout:).
rhenium
force-pushed
the
ky/ssl-handshake-timeout
branch
from
October 11, 2026 06:16
09f15f0 to
3896e94
Compare
Member
Author
|
Yes, the new method signature is |
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.
Add a keyword argument
timeoutto specify the total time allowed for the TLS handshake to complete. Inspired byAddrinfo#connect(timeout:)andTCPSocket.open(connect_timeout:).Applies on top of #1105