[#98621] Re: Function getlogin_r()'s protoype] — Bertram Scharpf <lists@...>
FYI,
3 messages
2020/06/02
[#98947] [Ruby master Feature#16986] Anonymous Struct literal — ko1@...
Issue #16986 has been reported by ko1 (Koichi Sasada).
66 messages
2020/06/26
[#98962] [Ruby master Bug#16988] Kernel.load loads file from current directory without '.' in path — misharinn@...
Issue #16988 has been reported by TheSmartnik (Nikita Misharin).
5 messages
2020/06/26
[#98969] [Ruby master Feature#16994] Sets: shorthand for frozen sets of symbols / strings — marcandre-ruby-core@...
Issue #16994 has been reported by marcandre (Marc-Andre Lafortune).
7 messages
2020/06/26
[#100117] [Ruby master Feature#16994] Sets: shorthand for frozen sets of symbols / strings
— matz@...
2020/09/25
Issue #16994 has been updated by matz (Yukihiro Matsumoto).
[ruby-core:98604] [Ruby master Feature#16476] Socket.getaddrinfo cannot be interrupted by Timeout.timeout
From:
shatrov@...
Date:
2020-06-01 10:20:06 UTC
List:
ruby-core #98604
Issue #16476 has been updated by kirs (Kir Shatrov).
mame (Yusuke Endoh) wrote in #note-7:
> We discussed this issue at the dev-meeting, and it requires @Glass_saga's review.
>
> Note:
>
> * It is uninterruptable under a platform that getaddrinfo_a is unavailable, but this problem is not only this proposal but also `timeout:` option of `Addrinfo.getaddrinfo()`.
> * Interruptable version can be implemented without getaddrinfo_a: Creating pthread for getaddrinfo function and pthread_cancel when interrupted. Contribution is welcome.
mame (Yusuke Endoh) wrote in #note-7:
> We discussed this issue at the dev-meeting, and it requires @Glass_saga's review.
>
> Note:
>
> * It is uninterruptable under a platform that getaddrinfo_a is unavailable, but this problem is not only this proposal but also `timeout:` option of `Addrinfo.getaddrinfo()`.
> * Interruptable version can be implemented without getaddrinfo_a: Creating pthread for getaddrinfo function and pthread_cancel when interrupted. Contribution is welcome.
Thanks for feedback!
I've opened https://github.com/ruby/ruby/pull/3171 with the approach you've described. Please let me know if I miss anything.
----------------------------------------
Feature #16476: Socket.getaddrinfo cannot be interrupted by Timeout.timeout
https://bugs.ruby-lang.org/issues/16476#change-85921
* Author: kirs (Kir Shatrov)
* Status: Assigned
* Priority: Normal
* Assignee: Glass_saga (Masaki Matsushita)
----------------------------------------
It seems like the blocking syscall done by `Socket.getaddrinfo` blocks Ruby VM in a way that Timeout.timeout has no effect.
See reproduction steps in getaddrinfo_interrupt.rb (https://gist.github.com/kirs/00c02ef92e0418578135fe0a6cbd3d7d). This affects all modern Ruby versions, including the latest 2.7.0.
Combined with default 10s resolv timeout on many Linux systems, this can have a very noticeable effect on production Ruby apps being not resilient to slow DNS resolutions, and being unable to fail fast even with `Timeout.timeout`.
While https://bugs.ruby-lang.org/issues/15553 improves the situation for `Addrinfo.getaddrinfo`, `Socket.getaddrinfo` is still blocking the VM and Timeout has no effect.
I'd like to discuss what could be done to make that call non-blocking for threads in Ruby VM.
**UPD:** looking closer, I can see that `Socket.getaddrinfo("www.ruby-lang.org", "http")` and `Addrinfo.getaddrinfo("www.ruby-lang.org", "http")` call non-interruptible `getaddrinfo`, while `Addrinfo.getaddrinfo("www.ruby-lang.org", "http", timeout: 10)` calls `getaddrinfo_a`, which is interruptible:
``` ruby
# interrupts as expected
Timeout.timeout(1) do
Addrinfo.getaddrinfo("www.ruby-lang.org", "http", timeout: 10)
end
```
I'd maybe suggest that we try to *always* use `getaddrinfo_a` when it's available, including in `Socket.getaddrinfo`. What downsides that would have?
I'd be happy to work on a patch.
--
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>