From 9c995e93d7b4fbc39e985c926761bdda645476de Mon Sep 17 00:00:00 2001 From: Sascha Schumann Date: Fri, 8 Oct 1999 16:24:31 +0000 Subject: [PATCH] Implement temporary workaround for thread-safety issues. This serializes all request accesses. To disable, define NO_GLOBAL_LOCK --- main/main.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/main/main.c b/main/main.c index 6860cc3ab0..1927534e8c 100644 --- a/main/main.c +++ b/main/main.c @@ -88,6 +88,21 @@ php_core_globals core_globals; PHPAPI int core_globals_id; #endif +/* temporary workaround for thread-safety issues in libzend */ +#if defined(ZTS) && !defined(NO_GLOBAL_LOCK) +static THREAD_T global_lock; +#define global_lock() tsrm_mutex_lock(global_lock) +#define global_unlock() tsrm_mutex_unlock(global_lock); +#define global_lock_init() global_lock = tsrm_mutex_alloc() +#define global_lock_destroy() tsrm_mutex_free(global_lock) +#else +#define global_lock() +#define global_unlock() +#define global_lock_init() +#define global_lock_destroy() +#endif + + void _php3_build_argv(char * ELS_DC); static void php3_timeout(int dummy); static void php3_set_timeout(long seconds); @@ -661,6 +676,8 @@ static void php_message_handler_for_zend(long message, void *data) int php_request_startup(CLS_D ELS_DC PLS_DC SLS_DC) { + global_lock(); + php_output_startup(); if (PG(output_buffering)) { @@ -760,6 +777,8 @@ void php_request_shutdown(void *dummy) request_info.php_argv0 = NULL; } #endif + + global_unlock(); } @@ -822,6 +841,7 @@ int php_module_startup(sapi_module_struct *sf) WSADATA wsaData; #endif + global_lock_init(); SG(server_context) = NULL; SG(request_info).request_method = NULL; sapi_activate(SLS_C); @@ -935,6 +955,7 @@ void php_module_shutdown() sapi_rqst->flush(sapi_rqst->scid); #endif + global_lock_destroy(); zend_shutdown(); UNREGISTER_INI_ENTRIES(); php_ini_mshutdown(); -- 2.40.0