8000 Introduce a timeout to prevent `rb_thread_fd_select` from hanging with write(2) failure by shioimm · Pull Request #12457 · ruby/ruby · GitHub
[go: up one dir, main page]

Skip to content

Introduce a timeout to prevent rb_thread_fd_select from hanging with write(2) failure #12457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion ext/socket/ipsocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,18 @@ init_fast_fallback_inetsock_internal(VALUE v)
delay = tv_to_timeout(ends_at, now);
delay_p = &delay;
} else {
delay_p = NULL;
if (((resolution_store.v6.finished && !resolution_store.v4.finished) ||
(resolution_store.v4.finished && !resolution_store.v6.finished)) &&
!any_addrinfos(&resolution_store) &&
!in_progress_fds(arg->connection_attempt_fds_size)) {
/* A limited timeout is introduced to prevent select(2) from hanging when it is exclusively
* waiting for name resolution and write(2) failure occurs in a child thread. */
delay.tv_sec = 0;
delay.tv_usec = 50000;
delay_p = &delay;
} else {
delay_p = NULL;
}
}

nfds = 0;
Expand Down Expand Up @@ -1040,6 +1051,7 @@ init_fast_fallback_inetsock_internal(VALUE v)
status = 0;
}

/* For cases where write(2) fails in child threads */
if (!resolution_store.is_all_finised) {
if (!resolution_store.v6.finished && arg->getaddrinfo_entries[IPV6_ENTRY_POS]->has_syserr) {
resolution_store.v6.finished = true;
Expand Down
Loading
0