diff options
author | Masaki Matsushita <[email protected]> | 2020-12-06 01:16:33 +0900 |
---|---|---|
committer | Masaki Matsushita <[email protected]> | 2020-12-06 01:32:43 +0900 |
commit | 76439eee68d2f1e56ac7a6ab38aceacf0b4b40c8 (patch) | |
tree | aaf937f3916e0db6ef96bd24dc9e4d4358caf4eb /process.c | |
parent | a38d4473564c5620d272305e91c4133f08034138 (diff) |
Call cleanup function for getaddrinfo_a(3) only before fork()
Previously, rb_getaddrinfo_a_before_exec() is called from before_exec().
However, the function needs to be called only before fork().
The change moves it to before_fork().
Diffstat (limited to 'process.c')
-rw-r--r-- | process.c | 23 |
1 files changed, 14 insertions, 9 deletions
@@ -332,7 +332,7 @@ static ID id_MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC; #endif static ID id_hertz; #ifdef HAVE_GETADDRINFO_A -void (* rb_socket_before_exec_func)() = NULL; +void (* rb_socket_before_fork_func)() = NULL; #endif /* execv and execl are async-signal-safe since SUSv4 (POSIX.1-2008, XPG7) */ @@ -1548,13 +1548,6 @@ before_exec_async_signal_safe(void) static void before_exec_non_async_signal_safe(void) { -#ifdef HAVE_GETADDRINFO_A - if (rb_socket_before_exec_func) { - /* A mitigation for [Bug #17220]. See ext/socket/raddrinfo.c */ - rb_socket_before_exec_func(); - } -#endif - /* * On Mac OS X 10.5.x (Leopard) or earlier, exec() may return ENOTSUP * if the process have multiple threads. Therefore we have to kill @@ -1628,7 +1621,19 @@ after_exec(void) } #if defined HAVE_WORKING_FORK || defined HAVE_DAEMON -#define before_fork_ruby() before_exec() +static void +before_fork_ruby(void) +{ +#ifdef HAVE_GETADDRINFO_A + if (rb_socket_before_fork_func) { + /* A mitigation for [Bug #17220]. See ext/socket/raddrinfo.c */ + rb_socket_before_fork_func(); + } +#endif + + before_exec(); +} + static void after_fork_ruby(void) { |