summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2024-07-10 00:55:04 +0900
committerGitHub <noreply@github.com>2024-07-09 08:55:04 -0700
commit3427a1679a8ca30465c684ac28449f495bff8a22 (patch)
tree04ce0128eb05fe000ceb9b612cd7f2ca45a016e7
parentbe1089c8ec5ba40e09b1553e36b3174bf4014d9d (diff)
retry on cancelling of `getaddrinfo` (#11131)
When the registerred unblock function is called, it should retry the cancelled blocking function if possible after checkints. For example, `SIGCHLD` can cancel this method, but it should not raise any exception if there is no trap handlers. The following is repro-code: ```ruby require 'socket' PN = 10_000 1000000.times{ p _1 PN.times{ fork{ sleep rand(0.3) } } i = 0 while i<PN cpid = Process.wait -1, Process::WNOHANG if cpid # p [i, cpid] i += 1 end begin TCPServer.new(nil, 0).close rescue p $! exit! end end } ```
-rw-r--r--ext/socket/raddrinfo.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c
index 2b3ec3a6b5..909c02752c 100644
--- a/ext/socket/raddrinfo.c
+++ b/ext/socket/raddrinfo.c
@@ -510,7 +510,7 @@ start:
if (err == 0) *ai = arg->ai;
}
else if (arg->cancelled) {
- err = EAI_AGAIN;
+ retry = 1;
}
else {
// If already interrupted, rb_thread_call_without_gvl2 may return without calling wait_getaddrinfo.
@@ -731,7 +731,7 @@ start:
}
}
else if (arg->cancelled) {
- err = EAI_AGAIN;
+ retry = 1;
}
else {
// If already interrupted, rb_thread_call_without_gvl2 may return without calling wait_getnameinfo.