Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use connect_timeout for initial connection #159

Merged
merged 1 commit into from
Feb 17, 2024

Conversation

jhawthorn
Copy link
Member

After the initial non-blocking connection call, we wait for the socket to become writable as a signal that it has been successful (non-blocking connects otherwise return immediately).

Previously this "writable" check used the write timeout instead of the connect timeout, which may have been confusing for users. IMO this was a bug introduced at some point prior to public release (at one time the writable check didn't exist and the connect_timeout worked as one would expect).

This commit adds a new TRILOGY_WAIT_CONNECT, which uses connect_timeout to wait for the connection to become writable. If connect_timeout isn't set it will use write_timeout for backwards compatibility.

After the initial non-blocking connection call, we wait for the socket
to become writable as a signal that it has been successful (non-blocking
connects otherwise return immediately).

Previously this "writable" check used the write timeout instead of the
connect timeout, which may have been confusing for users. IMO this was a
bug introduced at some point prior to public release (at one time
the writable check didn't exist and the connect_timeout worked as one
would expect).

This commit adds a new TRILOGY_WAIT_CONNECT, which uses connect_timeout
to wait for the connection to become writable. If connect_timeout isn't
set it will use write_timeout for backwards compatibility.

Co-authored-by: Daniel Colson <[email protected]>
@nirvdrum
Copy link
Contributor

FYI, Dalli started using connect_timeout recently and it's been problematic. That's not to say you shouldn't use connect_timeout, but I wanted to highlight that it could be problematic through Ruby 3.4 due to the presence of resolv-replace in the standard library.

@jhawthorn
Copy link
Member Author

Thanks for the warning. I think we're not going to hit any similar problems as this is our own :connect_timeout option not Socket's (though that's good to keep in mind for the future as I am interested in exploring using a Ruby socket)

@jhawthorn jhawthorn merged commit 0eb2487 into trilogy-libraries:main Feb 17, 2024
11 checks passed
@jhawthorn jhawthorn deleted the connect_timeout branch February 17, 2024 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants