[ruby-core:75846] [Ruby trunk Feature#12435] Using connect_nonblock to open TCP connections in Net::HTTP#connect
From:
naruse@...
Date:
2016-06-05 16:53:51 UTC
List:
ruby-core #75846
Issue #12435 has been updated by Yui NARUSE. It looks reasonable but I'm wondering TCPSocket.open should have such logic as timeout option. ---------------------------------------- Feature #12435: Using connect_nonblock to open TCP connections in Net::HTTP#connect https://bugs.ruby-lang.org/issues/12435#change-59021 * Author: Mohamed Hafez * Status: Open * Priority: Normal * Assignee: ---------------------------------------- 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... -- https://bugs.ruby-lang.org/ Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>