diff options
author | Joe Watkins <krakjoe@php.net> | 2019-03-29 19:06:59 +0100 |
---|---|---|
committer | Joe Watkins <krakjoe@php.net> | 2019-03-29 19:06:59 +0100 |
commit | abd0e015a8d126a8efee4b3625b500053ae9827d (patch) | |
tree | 8c2c90683002c3f7f30fdeacdb779cf71817d960 /TSRM | |
parent | 4006e995772fca4ae2821a0259693901dd229c68 (diff) | |
parent | 072eb6dd77b079a6f90ca5b155f9b0add1b5f2d4 (diff) | |
download | php-git-abd0e015a8d126a8efee4b3625b500053ae9827d.tar.gz |
Merge branch 'PHP-7.4'
* PHP-7.4:
tsrm environment lock
Diffstat (limited to 'TSRM')
-rw-r--r-- | TSRM/TSRM.c | 16 | ||||
-rw-r--r-- | TSRM/TSRM.h | 7 |
2 files changed, 22 insertions, 1 deletions
diff --git a/TSRM/TSRM.c b/TSRM/TSRM.c index 8b87476210..fa8e5f7736 100644 --- a/TSRM/TSRM.c +++ b/TSRM/TSRM.c @@ -52,7 +52,8 @@ static int resource_types_table_size; static size_t tsrm_reserved_pos = 0; static size_t tsrm_reserved_size = 0; -static MUTEX_T tsmm_mutex; /* thread-safe memory manager mutex */ +static MUTEX_T tsmm_mutex; /* thread-safe memory manager mutex */ +static MUTEX_T tsrm_env_mutex; /* tsrm environ mutex */ /* New thread handlers */ static tsrm_thread_begin_func_t tsrm_new_thread_begin_handler = NULL; @@ -145,6 +146,8 @@ TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debu tsrm_reserved_pos = 0; tsrm_reserved_size = 0; + tsrm_env_mutex = tsrm_mutex_alloc(); + return 1; }/*}}}*/ @@ -191,6 +194,8 @@ TSRM_API void tsrm_shutdown(void) } tsrm_mutex_free(tsmm_mutex); tsmm_mutex = NULL; + tsrm_mutex_free(tsrm_env_mutex); + tsrm_env_mutex = NULL; TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Shutdown TSRM")); if (tsrm_error_file!=stderr) { fclose(tsrm_error_file); @@ -212,6 +217,15 @@ TSRM_API void tsrm_shutdown(void) tsrm_reserved_size = 0; }/*}}}*/ +/* {{{ */ +/* environ lock api */ +TSRM_API int tsrm_env_lock() { + return tsrm_mutex_lock(tsrm_env_mutex); +} + +TSRM_API int tsrm_env_unlock() { + return tsrm_mutex_unlock(tsrm_env_mutex); +} /* }}} */ /* enlarge the arrays for the already active threads */ static void tsrm_update_active_threads(void) diff --git a/TSRM/TSRM.h b/TSRM/TSRM.h index 22ccf61744..d5d9065530 100644 --- a/TSRM/TSRM.h +++ b/TSRM/TSRM.h @@ -84,6 +84,10 @@ extern "C" { TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debug_level, char *debug_filename); TSRM_API void tsrm_shutdown(void); +/* environ lock API */ +TSRM_API int tsrm_env_lock(); +TSRM_API int tsrm_env_unlock(); + /* allocates a new thread-safe-resource id */ TSRM_API ts_rsrc_id ts_allocate_id(ts_rsrc_id *rsrc_id, size_t size, ts_allocate_ctor ctor, ts_allocate_dtor dtor); @@ -175,6 +179,9 @@ TSRM_API const char *tsrm_api_name(void); #else /* non ZTS */ +#define tsrm_env_lock() 0 +#define tsrm_env_unlock() 0 + #define TSRMG_STATIC(id, type, element) #define TSRMLS_CACHE_EXTERN() #define TSRMLS_CACHE_DEFINE() |