Thanks to Christian Heimes for pointing this out.
Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4191)
return 1;
}
+# ifdef OPENSSL_SYS_UNIX
+static pthread_once_t fork_once_control = PTHREAD_ONCE_INIT;
+
+static void fork_once_func(void)
+{
+ pthread_atfork(OPENSSL_fork_prepare,
+ OPENSSL_fork_parent, OPENSSL_fork_child);
+}
+# endif
+
int openssl_init_fork_handlers(void)
{
# ifdef OPENSSL_SYS_UNIX
- if (pthread_atfork(OPENSSL_fork_prepare,
- OPENSSL_fork_parent, OPENSSL_fork_child) == 0)
+ if (pthread_once(&fork_once_control, fork_once_func) == 0)
return 1;
# endif
return 0;