Skip to content

Commit 6c7685d

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

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

appsec/src/extension/ddappsec.c

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

5050
#if ZTS
5151
static atomic_int _thread_count;
52+
# if PHP_VERSION_ID < 70200
53+
static atomic_bool _ginit_called_once;
54+
# endif
5255
#endif
5356

5457
static void _check_enabled(void);
@@ -184,7 +187,12 @@ static PHP_GINIT_FUNCTION(ddappsec)
184187
// We don't really need to call _tshutdown_handler on the main thread,
185188
// though I guess we could do it maybe on MSHUTDOWN or GSHUTDOWN if we
186189
// detected it was running for the main thread globals there.
187-
if (!tsrm_is_main_thread()) {
190+
# if PHP_VERSION_ID >= 70200
191+
bool is_main_thread = tsrm_is_main_thread();
192+
# else
193+
bool is_main_thread = !atomic_exchange(&_ginit_called_once, true);
194+
# endif
195+
if (!is_main_thread) {
188196
# if defined(__linux__)
189197
extern void *__dso_handle;
190198
extern int __cxa_thread_atexit_impl(
@@ -232,6 +240,9 @@ static PHP_GSHUTDOWN_FUNCTION(ddappsec)
232240
dd_log_shutdown();
233241
zai_config_mshutdown();
234242
zai_json_shutdown_bindings();
243+
# if PHP_VERSION_ID < 70200
244+
atomic_store(&_ginit_called_once, false);
245+
# endif
235246
}
236247
#else
237248
dd_log_shutdown();

0 commit comments

Comments
 (0)