From: eregontp@... Date: 2019-02-06T19:08:45+00:00 Subject: [ruby-core:91441] [Ruby trunk Feature#15553] Addrinfo.getaddrinfo supports timeout Issue #15553 has been updated by Eregon (Benoit Daloze). akr (Akira Tanaka) wrote: > I think timeout library is not effective for getaddrinfo method (without getaddrinfo_a). That was also my experience trying to use SIGVTALRM to interrupt getaddrinfo(3): it had no effect, the code ignores EINTR and only ends after 5 seconds (its default timeout I guess). ---------------------------------------- Feature #15553: Addrinfo.getaddrinfo supports timeout https://bugs.ruby-lang.org/issues/15553#change-76699 * Author: Glass_saga (Masaki Matsushita) * Status: Open * Priority: Normal * Assignee: * Target version: 2.7 ---------------------------------------- Currently, we use Timeout in Net::HTTP and other standard libraries. lib/net/http.rb ``` 945 s = Timeout.timeout(@open_timeout, Net::OpenTimeout) { 946 begin 947 TCPSocket.open(conn_address, conn_port, @local_host, @local_port) 948 rescue => e 949 raise e, "Failed to open TCP connection to " + 950 "#{conn_address}:#{conn_port} (#{e.message})" 951 end 952 } ``` Socket.tcp supports connect_timeout, but Addrinfo.getaddrinfo doesn't support timeout. We need to use Timeout to wait name resolution. In this patch, Addrinfo.getaddrinfo support timeout and Socket.tcp accepts resolv_timeout. It uses getaddrinfo_a(3) if available, otherwise it uses Timeout. We can avoid thread creation to make a TCP connection if getaddrinfo_a(3) is available. ---Files-------------------------------- patch.diff (13.2 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: