[ruby-core:85374] [Ruby trunk Feature#14430] net/http: use Socket.tcp with connect_timeout, instead of TCPSocket.open wrapped in Timeout.timeout

From: carl.hoerberg@...
Date: 2018-02-04 12:37:04 UTC
List: ruby-core #85374
Issue #14430 has been updated by carl.hoerberg (Carl H旦rberg).


normalperson (Eric Wong) wrote:
>  
>  Unfortunately, we can't do this, yet.  The Addrinfo calls use
>  getaddrinfo(3) which doesn't support timeout natively.

Right, good catch. 

>  
>  2) update resolv-replace.rb to cover Addrinfo cases, including
>  nscd cache lookup for glibc compatibility.

Looking into this i realize that /etc/nsswitch.conf has be to taken into account first. And then maybe nscd, but very few distros (if any?) install it by default anymore, and it generally seems to have a very bad rep "around the internets". 

But which one do you suggest? Go down the route of Socket.tcp, but make the DNS resolving interruptible/async (without doing it in a separate threads) or to implement thread-less timeout in the VM and continue to rely on getinfoaddr from glibc? 

----------------------------------------
Feature #14430: net/http: use Socket.tcp with connect_timeout, instead of TCPSocket.open wrapped in Timeout.timeout
https://bugs.ruby-lang.org/issues/14430#change-70154

* Author: carl.hoerberg (Carl H旦rberg)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
Instead of using TCPSocket.open, wrapped in Timeout.timeout, that will create a temporary thread. By using Socket.tcp with the connect_timeout argument for open_timeout the connection opening is much more efficient as the kernels timeout is used instead. 

PR at: https://github.com/ruby/ruby/pull/1806



-- 
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>

In This Thread

Prev Next