Issue #15553 has been updated by Glass_saga (Masaki Matsushita).

File patch2.diff added

I updated the patch.

* get rid of Timeout from ext/socket/lib/socket.rb. If getaddrinfo_a() is not available, timeout is ignored.

----------------------------------------
Feature #15553: Addrinfo.getaddrinfo supports timeout
https://bugs.ruby-lang.org/issues/15553#change-77296

* 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)
patch2.diff (11.6 KB)


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