Merge branch 'PHP-7.4'

* PHP-7.4:
  Avoid reinitailization of ZTS cache pointer. Initialize it once in TSRM.c
This commit is contained in:
Dmitry Stogov 2019-03-12 17:36:02 +03:00
commit dbb462db5d
12 changed files with 15 additions and 15 deletions

View File

@ -19,9 +19,8 @@
typedef struct _tsrm_tls_entry tsrm_tls_entry;
#if defined(TSRM_WIN32)
/* TSRMLS_CACHE_DEFINE; is already done in Zend, this is being always compiled statically. */
#endif
TSRMLS_CACHE_EXTERN();
struct _tsrm_tls_entry {
void **storage;
@ -300,6 +299,7 @@ static void allocate_new_resource(tsrm_tls_entry **thread_resources_ptr, THREAD_
/* Set thread local storage to this new thread resources structure */
tsrm_tls_set(*thread_resources_ptr);
TSRMLS_CACHE = *thread_resources_ptr;
if (tsrm_new_thread_begin_handler) {
tsrm_new_thread_begin_handler(thread_id);

View File

@ -679,8 +679,6 @@ static void compiler_globals_dtor(zend_compiler_globals *compiler_globals) /* {{
static void executor_globals_ctor(zend_executor_globals *executor_globals) /* {{{ */
{
ZEND_TSRMLS_CACHE_UPDATE();
zend_startup_constants();
zend_copy_constants(executor_globals->zend_constants, GLOBAL_CONSTANTS_TABLE);
zend_init_rsrc_plist();
@ -780,7 +778,6 @@ int zend_startup(zend_utility_functions *utility_functions) /* {{{ */
zend_executor_globals *executor_globals;
extern ZEND_API ts_rsrc_id ini_scanner_globals_id;
extern ZEND_API ts_rsrc_id language_scanner_globals_id;
ZEND_TSRMLS_CACHE_UPDATE();
#else
extern zend_ini_scanner_globals ini_scanner_globals;
extern zend_php_scanner_globals language_scanner_globals;

View File

@ -2723,7 +2723,6 @@ static void alloc_globals_ctor(zend_alloc_globals *alloc_globals)
if (tmp && zend_atoi(tmp, 0)) {
zend_mm_use_huge_pages = 1;
}
ZEND_TSRMLS_CACHE_UPDATE();
alloc_globals->mm_heap = zend_mm_init();
}

View File

@ -87,7 +87,6 @@ void zend_signal_handler_defer(int signo, siginfo_t *siginfo, void *context)
zend_bool is_handling_safe = 1;
#ifdef ZTS
ZEND_TSRMLS_CACHE_UPDATE();
/* A signal could hit after TSRM shutdown, in this case globals are already freed. */
if (NULL == TSRMLS_CACHE || NULL == TSRMG_BULK_STATIC(zend_signal_globals_id, zend_signal_globals_t *)) {
is_handling_safe = 0;

View File

@ -56,9 +56,6 @@ static void _type_dtor(zval *zv)
static void sapi_globals_ctor(sapi_globals_struct *sapi_globals)
{
#ifdef ZTS
ZEND_TSRMLS_CACHE_UPDATE();
#endif
memset(sapi_globals, 0, sizeof(*sapi_globals));
zend_hash_init_ex(&sapi_globals->known_post_content_types, 8, NULL, _type_dtor, 1, 0);
php_setup_sapi_content_types();

View File

@ -79,7 +79,6 @@ static int php_output_handler_devnull_func(void **handler_context, php_output_co
* Initialize the module globals on MINIT */
static inline void php_output_init_globals(zend_output_globals *G)
{
ZEND_TSRMLS_CACHE_UPDATE();
memset(G, 0, sizeof(*G));
}
/* }}} */

View File

@ -476,7 +476,9 @@ php_apache_server_startup(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp
#ifdef ZTS
tsrm_startup(1, 1, 0, NULL);
(void)ts_resource(0);
# ifdef PHP_WIN32
ZEND_TSRMLS_CACHE_UPDATE();
# endif
#endif
zend_signal_startup();
@ -574,7 +576,9 @@ static int php_handler(request_rec *r)
#ifdef ZTS
/* initial resource fetch */
(void)ts_resource(0);
# ifdef PHP_WIN32
ZEND_TSRMLS_CACHE_UPDATE();
# endif
#endif
#define PHPAP_INI_OFF php_apache_ini_dtor(r, parent_req);

View File

@ -1532,7 +1532,7 @@ PHP_INI_END()
*/
static void php_cgi_globals_ctor(php_cgi_globals_struct *php_cgi_globals)
{
#ifdef ZTS
#if defined(ZTS) && defined(PHP_WIN32)
ZEND_TSRMLS_CACHE_UPDATE();
#endif
php_cgi_globals->rfc2616_headers = 0;
@ -1793,7 +1793,9 @@ int main(int argc, char *argv[])
#ifdef ZTS
tsrm_startup(1, 1, 0, NULL);
(void)ts_resource(0);
# ifdef PHP_WIN32
ZEND_TSRMLS_CACHE_UPDATE();
# endif
#endif
zend_signal_startup();

View File

@ -1248,7 +1248,9 @@ int main(int argc, char *argv[])
#ifdef ZTS
tsrm_startup(1, 1, 0, NULL);
(void)ts_resource(0);
# ifdef PHP_WIN32
ZEND_TSRMLS_CACHE_UPDATE();
# endif
#endif
zend_signal_startup();

View File

@ -1296,9 +1296,6 @@ out:
static int php_cli_server_request_ctor(php_cli_server_request *req) /* {{{ */
{
#ifdef ZTS
ZEND_TSRMLS_CACHE_UPDATE();
#endif
req->protocol_version = 0;
req->request_uri = NULL;
req->request_uri_len = 0;

View File

@ -173,7 +173,9 @@ EMBED_SAPI_API int php_embed_init(int argc, char **argv)
#ifdef ZTS
tsrm_startup(1, 1, 0, NULL);
(void)ts_resource(0);
# ifdef PHP_WIN32
ZEND_TSRMLS_CACHE_UPDATE();
# endif
#endif
zend_signal_startup();

View File

@ -1418,7 +1418,9 @@ phpdbg_main:
#ifdef ZTS
tsrm_startup(1, 1, 0, NULL);
(void)ts_resource(0);
# ifdef PHP_WIN32
ZEND_TSRMLS_CACHE_UPDATE();
# endif
#endif
zend_signal_startup();