Project

General

Profile

Actions

Feature #12435

open

Using connect_nonblock to open TCP connections in Net::HTTP#connect

Added by mohamedhafez (Mohamed Hafez) almost 8 years ago. Updated almost 8 years ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:75763]

Description

Hey all, I've got a pull request at https://github.com/ruby/ruby/pull/1370 to start using connect_nonblock to open the TCP socket in Net::HTTP#connect, instead of doing a blocking connect that uses Timeout.timeout to look for timeouts. Using connect_nonblock is more efficient since it doesn't involve spinning up a separate thread to watch for timeouts, and also it avoids the race conditions inherent in the use of Timeout.timeout, as detailed in http://blog.headius.com/2008/02/ruby-threadraise-threadkill-timeoutrb.html

Over the last few versions of ruby there have been analogous fixes accepted to do this for opening an SSL connection in Net::HTTP#connect, so I'm guessing this shouldn't be too controversial, unless there is some issue I'm not aware of that kept the maintainers from implementing this as well...


Related issues 1 (1 open0 closed)

Related to Ruby master - Feature #12928: Use socket conect_timeout in net stdlib for open_timeoutOpenActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0