* [ruby-core:102005] [Ruby master Feature#17528] Make Addrinfo.getaddrinfo fall back to Timeout.timeout for :resolv_timeout
@ 2021-01-11 20:53 mohamed.m.m.hafez
2021-01-12 4:57 ` [ruby-core:102015] " akr
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: mohamed.m.m.hafez @ 2021-01-11 20:53 UTC (permalink / raw)
To: ruby-core
Issue #17528 has been reported by mohamedhafez (Mohamed Hafez).
----------------------------------------
Feature #17528: Make Addrinfo.getaddrinfo fall back to Timeout.timeout for :resolv_timeout
https://bugs.ruby-lang.org/issues/17528
* 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/
^ permalink raw reply [flat|nested] 5+ messages in thread
* [ruby-core:102015] [Ruby master Feature#17528] Make Addrinfo.getaddrinfo fall back to Timeout.timeout for :resolv_timeout
2021-01-11 20:53 [ruby-core:102005] [Ruby master Feature#17528] Make Addrinfo.getaddrinfo fall back to Timeout.timeout for :resolv_timeout mohamed.m.m.hafez
@ 2021-01-12 4:57 ` akr
2021-01-13 16:05 ` [ruby-core:102063] " mohamed.m.m.hafez
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: akr @ 2021-01-12 4:57 UTC (permalink / raw)
To: ruby-core
Issue #17528 has been updated by akr (Akira Tanaka).
I think Timeout.timeout doesn't work for Addrinfo.getaddrinfo
because Timeout.timeout cannot interrupt getaddrinfo function in C.
----------------------------------------
Feature #17528: Make Addrinfo.getaddrinfo fall back to Timeout.timeout for :resolv_timeout
https://bugs.ruby-lang.org/issues/17528#change-89863
* 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/
^ permalink raw reply [flat|nested] 5+ messages in thread
* [ruby-core:102063] [Ruby master Feature#17528] Make Addrinfo.getaddrinfo fall back to Timeout.timeout for :resolv_timeout
2021-01-11 20:53 [ruby-core:102005] [Ruby master Feature#17528] Make Addrinfo.getaddrinfo fall back to Timeout.timeout for :resolv_timeout mohamed.m.m.hafez
2021-01-12 4:57 ` [ruby-core:102015] " akr
@ 2021-01-13 16:05 ` mohamed.m.m.hafez
2021-01-13 17:50 ` [ruby-core:102069] " akr
2021-01-13 20:50 ` [ruby-core:102072] " mohamed.m.m.hafez
3 siblings, 0 replies; 5+ messages in thread
From: mohamed.m.m.hafez @ 2021-01-13 16:05 UTC (permalink / raw)
To: ruby-core
Issue #17528 has been updated by mohamedhafez (Mohamed Hafez).
According to https://bugs.ruby-lang.org/issues/12435, the only reason we are using `Timeout.timeout` in `Net::HTTP#connect` instead of using nonblocking io and `IO.select` is so that we can place a timeout on the getaddrinfo function, @normalperson can you clarify here?
----------------------------------------
Feature #17528: Make Addrinfo.getaddrinfo fall back to Timeout.timeout for :resolv_timeout
https://bugs.ruby-lang.org/issues/17528#change-89924
* 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/
^ permalink raw reply [flat|nested] 5+ messages in thread
* [ruby-core:102069] [Ruby master Feature#17528] Make Addrinfo.getaddrinfo fall back to Timeout.timeout for :resolv_timeout
2021-01-11 20:53 [ruby-core:102005] [Ruby master Feature#17528] Make Addrinfo.getaddrinfo fall back to Timeout.timeout for :resolv_timeout mohamed.m.m.hafez
2021-01-12 4:57 ` [ruby-core:102015] " akr
2021-01-13 16:05 ` [ruby-core:102063] " mohamed.m.m.hafez
@ 2021-01-13 17:50 ` akr
2021-01-13 20:50 ` [ruby-core:102072] " mohamed.m.m.hafez
3 siblings, 0 replies; 5+ messages in thread
From: akr @ 2021-01-13 17:50 UTC (permalink / raw)
To: ruby-core
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 <main>'
from /home/akr/o0/lib/ruby/3.1.0/timeout.rb:112:in `timeout'
from -e:1:in `<main>'
./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/
^ permalink raw reply [flat|nested] 5+ messages in thread
* [ruby-core:102072] [Ruby master Feature#17528] Make Addrinfo.getaddrinfo fall back to Timeout.timeout for :resolv_timeout
2021-01-11 20:53 [ruby-core:102005] [Ruby master Feature#17528] Make Addrinfo.getaddrinfo fall back to Timeout.timeout for :resolv_timeout mohamed.m.m.hafez
` (2 preceding siblings ...)
2021-01-13 17:50 ` [ruby-core:102069] " akr
@ 2021-01-13 20:50 ` mohamed.m.m.hafez
3 siblings, 0 replies; 5+ messages in thread
From: mohamed.m.m.hafez @ 2021-01-13 20:50 UTC (permalink / raw)
To: ruby-core
Issue #17528 has been updated by mohamedhafez (Mohamed Hafez).
I was just doing a similar test actually, I think your correct! I'll close this issue and re-submit a patch to Net::HTTP to replace `Timeout::timeout` there, since it's not doing anything for DNS lookups anyway. Thank you!
----------------------------------------
Feature #17528: Make Addrinfo.getaddrinfo fall back to Timeout.timeout for :resolv_timeout
https://bugs.ruby-lang.org/issues/17528#change-89932
* 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/
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-01-13 20:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-11 20:53 [ruby-core:102005] [Ruby master Feature#17528] Make Addrinfo.getaddrinfo fall back to Timeout.timeout for :resolv_timeout mohamed.m.m.hafez
2021-01-12 4:57 ` [ruby-core:102015] " akr
2021-01-13 16:05 ` [ruby-core:102063] " mohamed.m.m.hafez
2021-01-13 17:50 ` [ruby-core:102069] " akr
2021-01-13 20:50 ` [ruby-core:102072] " mohamed.m.m.hafez
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).