From c56a1c1953bf25581a6a0cd4ade22d2691a920e0 Mon Sep 17 00:00:00 2001 From: Masaki Matsushita Date: Sat, 5 Dec 2020 18:05:09 +0900 Subject: [PATCH] Extend sleep time to 1.5 second in rb_getaddrinfo_a_before_exec() After 94d49ed31c, TestSocket#test_getaddrinfo_after_fork fails in some platforms. To avoid this, the change extends sleep time to 1.5 second. --- ext/socket/raddrinfo.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c index 07659a760d..249ce035fd 100644 --- a/ext/socket/raddrinfo.c +++ b/ext/socket/raddrinfo.c @@ -436,6 +436,8 @@ gaicbs_wait_all(void) gai_suspend(reqs, size, NULL); // ignore result intentionally } +#define MILLISECOND_IN_NANOSECONDS 1000000 + /* A mitigation for [Bug #17220]. It cancels all outstanding requests and waits for ongoing requests. Then, it waits internal worker threads in getaddrinfo_a(3) to be finished. */ @@ -447,7 +449,8 @@ rb_getaddrinfo_a_before_exec(void) /* wait worker threads in getaddrinfo_a(3) to be finished. they will finish after 1 second sleep. */ - sleep(1); + struct timespec ts = {1, 500 * MILLISECOND_IN_NANOSECONDS}; + nanosleep(&ts, NULL); } int