File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4949
5050#if ZTS
5151static atomic_int _thread_count ;
52+ static atomic_bool _ginit_called_once ;
5253#endif
5354
5455static void _check_enabled (void );
@@ -184,7 +185,12 @@ static PHP_GINIT_FUNCTION(ddappsec)
184185 // We don't really need to call _tshutdown_handler on the main thread,
185186 // though I guess we could do it maybe on MSHUTDOWN or GSHUTDOWN if we
186187 // detected it was running for the main thread globals there.
187- if (!tsrm_is_main_thread ()) {
188+ # if PHP_VERSION_ID >= 70200
189+ bool is_main_thread = tsrm_is_main_thread ();
190+ # else
191+ bool is_main_thread = !atomic_exchange (& _ginit_called_once , true);
192+ # endif
193+ if (!is_main_thread ) {
188194# if defined(__linux__ )
189195 extern void * __dso_handle ;
190196 extern int __cxa_thread_atexit_impl (
@@ -232,6 +238,7 @@ static PHP_GSHUTDOWN_FUNCTION(ddappsec)
232238 dd_log_shutdown ();
233239 zai_config_mshutdown ();
234240 zai_json_shutdown_bindings ();
241+ atomic_store (_ginit_called_once , false);
235242 }
236243#else
237244 dd_log_shutdown ();
You can’t perform that action at this time.
0 commit comments