File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -90,6 +90,10 @@ __thread HashTable *sandboxed_env = NULL;
9090#ifndef PHP_WIN32
9191static bool is_forked_child = false;
9292static void frankenphp_fork_child (void ) { is_forked_child = true; }
93+
94+ static void frankenphp_register_atfork (void ) {
95+ pthread_atfork (NULL , NULL , frankenphp_fork_child );
96+ }
9397#endif
9498
9599void frankenphp_update_local_thread_context (bool is_worker ) {
@@ -711,7 +715,9 @@ PHP_FUNCTION(frankenphp_log) {
711715PHP_MINIT_FUNCTION (frankenphp ) {
712716 register_frankenphp_symbols (module_number );
713717#ifndef PHP_WIN32
714- pthread_atfork (NULL , NULL , frankenphp_fork_child );
718+ /* MINIT runs once per ZTS thread — guard the atfork registration */
719+ static pthread_once_t atfork_once = PTHREAD_ONCE_INIT ;
720+ pthread_once (& atfork_once , frankenphp_register_atfork );
715721#endif
716722
717723 zend_function * func ;
You can’t perform that action at this time.
0 commit comments