Skip to content

Commit 57cdd5c

Browse files
committed
fix borked merge
1 parent 2920b0d commit 57cdd5c

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

frankenphp.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ static void frankenphp_fork_child(void) {
162162
pthread_detach(watcher);
163163
#endif
164164
}
165+
166+
static void frankenphp_register_atfork(void) {
167+
pthread_atfork(frankenphp_fork_prepare, NULL, frankenphp_fork_child);
168+
}
165169
#endif
166170

167171
/* Best-effort force-kill for stuck PHP threads.
@@ -927,8 +931,10 @@ static const zend_function_entry frankenphp_test_hook_functions[] = {
927931

928932
PHP_MINIT_FUNCTION(frankenphp) {
929933
register_frankenphp_symbols(module_number);
930-
#ifndef
931-
pthread_atfork(frankenphp_fork_prepare, NULL, frankenphp_fork_child);
934+
#ifndef PHP_WIN32
935+
/* MINIT runs once per ZTS thread — guard the atfork registration */
936+
static pthread_once_t atfork_once = PTHREAD_ONCE_INIT;
937+
pthread_once(&atfork_once, frankenphp_register_atfork);
932938
#endif
933939

934940
#ifdef FRANKENPHP_TEST

0 commit comments

Comments
 (0)