From: akr@... Date: 2021-01-13T17:50:12+00:00 Subject: [ruby-core:102069] [Ruby master Feature#17528] Make Addrinfo.getaddrinfo fall back to Timeout.timeout for :resolv_timeout Issue #17528 has been updated by akr (Akira Tanaka). How to test: ``` % vi /etc/resolv.conf # specify non-existing nameserver % time ./ruby -rtimeout -rsocket -e 'Timeout.timeout(2) { Addrinfo.getaddrinfo("www.ruby-lang.org",nil) }' -e:1:in `getaddrinfo': execution expired (Timeout::Error) from -e:1:in `block in
' from /home/akr/o0/lib/ruby/3.1.0/timeout.rb:112:in `timeout' from -e:1:in `
' ./ruby -rtimeout -rsocket -e 0.14s user 0.00s system 0% cpu 20.136 total ``` This needs 20 second instead of 2 second. ---------------------------------------- Feature #17528: Make Addrinfo.getaddrinfo fall back to Timeout.timeout for :resolv_timeout https://bugs.ruby-lang.org/issues/17528#change-89930 * Author: mohamedhafez (Mohamed Hafez) * Status: Open * Priority: Normal ---------------------------------------- Currently, `Addrinfo.getaddrinfo` ignores the `:resolv_timeout` option if we are on a system without `getaddrinfo_a`. It would be great if instead it would fall back to using `Timeout.timeout`. That way, we could get rid of a lot of the usage of `Timeout.timeout` for systems that *do* have `getaddrinfo_a`. For example, for Net::HTTP#connect we could easily then do something like this: https://github.com/ruby/ruby/compare/master...mohamedhafez:patch-3?diff=split. The motivation for this is that the usage of Timeout.timeout is inherently unsafe, and it would be great to stop using it where we can (see https://www.mikeperham.com/2015/05/08/timeout-rubys-most-dangerous-api/ and http://blog.headius.com/2008/02/ruby-threadraise-threadkill-timeoutrb.html) -- https://bugs.ruby-lang.org/ Unsubscribe: