From: Dmitry Stogov Date: Thu, 2 Nov 2017 20:29:21 +0000 (+0300) Subject: Switch back from "request" interned strings storage to "permanent" in MSHUTDOWN X-Git-Tag: php-7.3.0alpha1~1098 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f2b91b31e4625f953e57ed68ce992a72bc6e7846;p=php Switch back from "request" interned strings storage to "permanent" in MSHUTDOWN --- diff --git a/Zend/zend_string.c b/Zend/zend_string.c index a5ecd411ba..2fcaefcbdc 100644 --- a/Zend/zend_string.c +++ b/Zend/zend_string.c @@ -38,6 +38,7 @@ static HashTable interned_strings_permanent; static zend_new_interned_string_func_t interned_string_request_handler = zend_new_interned_string_request; static zend_string_init_interned_func_t interned_string_init_request_handler = zend_string_init_interned_request; static zend_string_copy_storage_func_t interned_string_copy_storage = NULL; +static zend_string_copy_storage_func_t interned_string_restore_storage = NULL; ZEND_API zend_string *zend_empty_string = NULL; ZEND_API zend_string *zend_one_char_string[256]; @@ -254,18 +255,27 @@ ZEND_API void zend_interned_strings_set_request_storage_handlers(zend_new_intern interned_string_init_request_handler = init_handler; } -ZEND_API void zend_interned_strings_set_permanent_storage_copy_handler(zend_string_copy_storage_func_t handler) +ZEND_API void zend_interned_strings_set_permanent_storage_copy_handlers(zend_string_copy_storage_func_t copy_handler, zend_string_copy_storage_func_t restore_handler) { - interned_string_copy_storage = handler; + interned_string_copy_storage = copy_handler; + interned_string_restore_storage = restore_handler; } -ZEND_API void zend_interned_strings_switch_storage(void) +ZEND_API void zend_interned_strings_switch_storage(zend_bool request) { - if (interned_string_copy_storage) { - interned_string_copy_storage(); + if (request) { + if (interned_string_copy_storage) { + interned_string_copy_storage(); + } + zend_new_interned_string = interned_string_request_handler; + zend_string_init_interned = interned_string_init_request_handler; + } else { + zend_new_interned_string = zend_new_interned_string_permanent; + zend_string_init_interned = zend_string_init_interned_permanent; + if (interned_string_restore_storage) { + interned_string_restore_storage(); + } } - zend_new_interned_string = interned_string_request_handler; - zend_string_init_interned = interned_string_init_request_handler; } /* diff --git a/Zend/zend_string.h b/Zend/zend_string.h index a506d2ce77..72a9b7d1bb 100644 --- a/Zend/zend_string.h +++ b/Zend/zend_string.h @@ -39,8 +39,8 @@ ZEND_API void zend_interned_strings_activate(void); ZEND_API void zend_interned_strings_deactivate(void); ZEND_API zend_string *zend_interned_string_find_permanent(zend_string *str); ZEND_API void zend_interned_strings_set_request_storage_handlers(zend_new_interned_string_func_t handler, zend_string_init_interned_func_t init_handler); -ZEND_API void zend_interned_strings_set_permanent_storage_copy_handler(zend_string_copy_storage_func_t handler); -ZEND_API void zend_interned_strings_switch_storage(void); +ZEND_API void zend_interned_strings_set_permanent_storage_copy_handlers(zend_string_copy_storage_func_t copy_handler, zend_string_copy_storage_func_t restore_handler); +ZEND_API void zend_interned_strings_switch_storage(zend_bool request); ZEND_API extern zend_string *zend_empty_string; ZEND_API extern zend_string *zend_one_char_string[256]; diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 1d31489429..e6a31fba45 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -2467,7 +2467,7 @@ static int zend_accel_init_shm(void) ZCSG(interned_strings_end) = ZCSG(interned_strings_start) + (ZCG(accel_directives).interned_strings_buffer * 1024 * 1024); ZCSG(interned_strings_top) = ZCSG(interned_strings_start); ZCSG(interned_strings_saved_top) = NULL; - zend_interned_strings_set_permanent_storage_copy_handler(accel_use_shm_interned_strings); + zend_interned_strings_set_permanent_storage_copy_handlers(accel_use_shm_interned_strings, accel_use_permanent_interned_strings); } zend_interned_strings_set_request_storage_handlers(accel_new_interned_string_for_php, accel_init_interned_string_for_php); @@ -2737,7 +2737,7 @@ static int accel_post_startup(void) zend_shared_alloc_lock(); accel_shared_globals = (zend_accel_shared_globals *) ZSMMG(app_shared_globals); if (ZCG(accel_directives).interned_strings_buffer) { - zend_interned_strings_set_permanent_storage_copy_handler(accel_use_shm_interned_strings); + zend_interned_strings_set_permanent_storage_copy_handlers(accel_use_shm_interned_strings, accel_use_permanent_interned_strings); } zend_interned_strings_set_request_storage_handlers(accel_new_interned_string_for_php, accel_init_interned_string_for_php); zend_shared_alloc_unlock(); @@ -2863,10 +2863,6 @@ void accel_shutdown(void) file_cache_only = ZCG(accel_directives).file_cache_only; #endif - if (!file_cache_only && ZCG(accel_directives).interned_strings_buffer) { - accel_use_permanent_interned_strings(); - } - accel_reset_pcre_cache(); accel_free_ts_resources(); diff --git a/main/main.c b/main/main.c index 962b9d5e9b..7b43e2e0f0 100644 --- a/main/main.c +++ b/main/main.c @@ -2280,7 +2280,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod shutdown_memory_manager(1, 0); virtual_cwd_activate(); - zend_interned_strings_switch_storage(); + zend_interned_strings_switch_storage(1); /* we're done */ return retval; @@ -2313,6 +2313,8 @@ void php_module_shutdown(void) return; } + zend_interned_strings_switch_storage(0); + #ifdef ZTS ts_free_worker_threads(); #endif