Skip to content

Commit 1c54947

Browse files
committed
fix for php 7.0 and 7.1
1 parent 3c90bf0 commit 1c54947

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

appsec/src/extension/ddappsec.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949

5050
#if ZTS
5151
static atomic_int _thread_count;
52+
static atomic_bool _ginit_called_once;
5253
#endif
5354

5455
static 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();

0 commit comments

Comments
 (0)