diff options
author | Misaki Shioi <[email protected]> | 2024-12-11 18:57:23 +0900 |
---|---|---|
committer | <[email protected]> | 2024-12-11 18:57:23 +0900 |
commit | f9601903f64e56d95c140074980584c09373b040 () | |
tree | d21ad3b2c778aa5b23dc11fbc2f031ed59a3dc54 /ext/socket/raddrinfo.c | |
parent | bbf839dfe2c7f5f252afb8cfbe92d792c9f53178 (diff) |
Use `rb_thread_fd_select` instead of select(2) (#12292)
* Use `rb_thread_fd_select` instead of select(2) For fixing https://bugs.ruby-lang.org/issues/20932 . `TCPSocket.new`, which internally uses select(2) for HEv2, can cause SEGV if the number of file descriptors exceeds `FD_SETSIZE`. This change avoids that issue by replacing select(2) with `rb_thread_fd_select`, which is provided as part of Ruby's internal API. --- This includes the following changes. * rb_thread_fd_select does not need common pipe
Notes: Merged-By: shioimm <[email protected]>
-rw-r--r-- | ext/socket/raddrinfo.c | 17 |
1 files changed, 5 insertions, 12 deletions
@@ -3095,19 +3095,12 @@ do_fast_fallback_getaddrinfo(void *ptr) rb_nativethread_lock_lock(&shared->lock); { entry->err = err; - if (shared->cancelled) { - if (entry->ai) { - freeaddrinfo(entry->ai); - entry->ai = NULL; - } - } else { - const char notification = entry->family == AF_INET6 ? - IPV6_HOSTNAME_RESOLVED : IPV4_HOSTNAME_RESOLVED; - if (shared->notify != -1 && (write(shared->notify, ¬ification, 1)) < 0) { - entry->err = errno; - entry->has_syserr = true; - } } if (--(entry->refcount) == 0) need_free = 1; if (--(shared->refcount) == 0) shared_need_free = 1; |