diff options
author | Dmitry Stogov <dmitry@zend.com> | 2018-03-05 16:01:43 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2018-03-05 16:01:43 +0300 |
commit | 350082ed7146fd889d04c8864d8d649bea73dd01 (patch) | |
tree | 46346a44f9670144e97088251f5e3180f693c710 | |
parent | a827aefe47dafed918c5e57a7e9e92ac52378792 (diff) | |
download | php-git-350082ed7146fd889d04c8864d8d649bea73dd01.tar.gz |
Fixed "opcache.file_cache_fallback" mode.
It's not safe to change value of ZCG(accel_directives).file_cache_only, becuse it might be altered by INI subsystem.
Use global variable instead.
-rw-r--r-- | ext/opcache/ZendAccelerator.c | 22 | ||||
-rw-r--r-- | ext/opcache/ZendAccelerator.h | 5 | ||||
-rw-r--r-- | ext/opcache/shared_alloc_win32.c | 3 | ||||
-rw-r--r-- | ext/opcache/zend_accelerator_module.c | 10 | ||||
-rw-r--r-- | ext/opcache/zend_file_cache.c | 2 | ||||
-rw-r--r-- | ext/opcache/zend_persist.c | 2 |
6 files changed, 27 insertions, 17 deletions
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 9cab01daaa..11b2c4ea77 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -108,6 +108,9 @@ zend_accel_shared_globals *accel_shared_globals = NULL; zend_bool accel_startup_ok = 0; static char *zps_failure_reason = NULL; char *zps_api_failure_reason = NULL; +#ifdef HAVE_OPCACHE_FILE_CACHE +zend_bool file_cache_only = 0; /* process uses file cache only */ +#endif #if ENABLE_FILE_CACHE_FALLBACK zend_bool fallback_process = 0; /* process uses file cache fallback */ #endif @@ -448,7 +451,7 @@ zend_string *accel_new_interned_string(zend_string *str) Bucket *p; #ifdef HAVE_OPCACHE_FILE_CACHE - if (ZCG(accel_directives).file_cache_only) { + if (file_cache_only) { return str; } #endif @@ -1700,7 +1703,7 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type) /* The Accelerator is disabled, act as if without the Accelerator */ return accelerator_orig_compile_file(file_handle, type); #ifdef HAVE_OPCACHE_FILE_CACHE - } else if (ZCG(accel_directives).file_cache_only) { + } else if (file_cache_only) { return file_cache_compile_file(file_handle, type); #endif } else if ((!ZCG(counted) && !ZCSG(accelerator_enabled)) || @@ -1999,6 +2002,9 @@ static int persistent_stream_open_function(const char *filename, zend_file_handl static zend_string* persistent_zend_resolve_path(const char *filename, int filename_len) { if (ZCG(enabled) && accel_startup_ok && +#ifdef HAVE_OPCACHE_FILE_CACHE + !file_cache_only && +#endif (ZCG(counted) || ZCSG(accelerator_enabled)) && !ZCSG(restart_in_progress)) { @@ -2130,7 +2136,7 @@ static void accel_activate(void) ZCG(cwd_check) = 1; #ifdef HAVE_OPCACHE_FILE_CACHE - if (ZCG(accel_directives).file_cache_only) { + if (file_cache_only) { return; } #endif @@ -2801,7 +2807,8 @@ static int accel_startup(zend_extension *extension) /* End of non-SHM dependent initializations */ /********************************************/ #ifdef HAVE_OPCACHE_FILE_CACHE - if (!ZCG(accel_directives).file_cache_only) { + file_cache_only = ZCG(accel_directives).file_cache_only; + if (!file_cache_only) { #else if (1) { #endif @@ -2839,6 +2846,7 @@ static int accel_startup(zend_extension *extension) #if ENABLE_FILE_CACHE_FALLBACK case ALLOC_FALLBACK: zend_shared_alloc_lock(); + file_cache_only = 1; fallback_process = 1; zend_accel_init_auto_globals(); zend_shared_alloc_unlock(); @@ -2937,7 +2945,7 @@ static void accel_free_ts_resources() void accel_shutdown(void) { zend_ini_entry *ini_entry; - zend_bool file_cache_only = 0; + zend_bool _file_cache_only = 0; zend_optimizer_shutdown(); @@ -2964,12 +2972,12 @@ void accel_shutdown(void) zend_interned_strings_restore = orig_interned_strings_restore; #ifdef HAVE_OPCACHE_FILE_CACHE - file_cache_only = ZCG(accel_directives).file_cache_only; + _file_cache_only = file_cache_only; #endif accel_free_ts_resources(); - if (!file_cache_only) { + if (!_file_cache_only) { zend_shared_alloc_shutdown(); } zend_compile_file = accelerator_orig_compile_file; diff --git a/ext/opcache/ZendAccelerator.h b/ext/opcache/ZendAccelerator.h index bc90d1b436..d0f69d6b7c 100644 --- a/ext/opcache/ZendAccelerator.h +++ b/ext/opcache/ZendAccelerator.h @@ -120,6 +120,8 @@ extern int lock_file; #if defined(HAVE_OPCACHE_FILE_CACHE) && defined(ZEND_WIN32) # define ENABLE_FILE_CACHE_FALLBACK 1 +#else +# define ENABLE_FILE_CACHE_FALLBACK 0 #endif #if ZEND_WIN32 @@ -284,6 +286,9 @@ typedef struct _zend_accel_shared_globals { } zend_accel_shared_globals; extern zend_bool accel_startup_ok; +#ifdef HAVE_OPCACHE_FILE_CACHE +extern zend_bool file_cache_only; +#endif #if ENABLE_FILE_CACHE_FALLBACK extern zend_bool fallback_process; #endif diff --git a/ext/opcache/shared_alloc_win32.c b/ext/opcache/shared_alloc_win32.c index 7b75b1eb69..0356e70420 100644 --- a/ext/opcache/shared_alloc_win32.c +++ b/ext/opcache/shared_alloc_win32.c @@ -182,9 +182,6 @@ static int zend_shared_alloc_reattach(size_t requested_size, char **error_in) } accel_shared_globals = (zend_accel_shared_globals *)((char *)((zend_smm_shared_globals *)mapping_base)->app_shared_globals + ((char *)mapping_base - (char *)wanted_mb_save)); - /* Make this process to use file-cache only */ - ZCG(accel_directives).file_cache_only = 1; - return ALLOC_FALLBACK; } #endif diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c index b7c24c377e..6c953abc55 100644 --- a/ext/opcache/zend_accelerator_module.c +++ b/ext/opcache/zend_accelerator_module.c @@ -406,7 +406,7 @@ void zend_accel_override_file_functions(void) zend_function *old_function; if (ZCG(enabled) && accel_startup_ok && ZCG(accel_directives).file_override_enabled) { #ifdef HAVE_OPCACHE_FILE_CACHE - if (ZCG(accel_directives).file_cache_only) { + if (file_cache_only) { zend_accel_error(ACCEL_LOG_WARNING, "file_override_enabled has no effect when file_cache_only is set"); return; } @@ -442,7 +442,7 @@ void zend_accel_info(ZEND_MODULE_INFO_FUNC_ARGS) if (ZCG(enabled) && accel_startup_ok && #ifdef HAVE_OPCACHE_FILE_CACHE - ((ZCG(counted) || ZCSG(accelerator_enabled)) || ZCG(accel_directives).file_cache_only) + ((ZCG(counted) || ZCSG(accelerator_enabled)) || file_cache_only) #else (ZCG(counted) || ZCSG(accelerator_enabled)) #endif @@ -457,7 +457,7 @@ void zend_accel_info(ZEND_MODULE_INFO_FUNC_ARGS) php_info_print_table_row(2, "Optimization", "Disabled"); } #ifdef HAVE_OPCACHE_FILE_CACHE - if (!ZCG(accel_directives).file_cache_only) { + if (!file_cache_only) { php_info_print_table_row(2, "SHM Cache", "Enabled"); } else { php_info_print_table_row(2, "SHM Cache", "Disabled"); @@ -467,7 +467,7 @@ void zend_accel_info(ZEND_MODULE_INFO_FUNC_ARGS) } else { php_info_print_table_row(2, "File Cache", "Disabled"); } - if (ZCG(accel_directives).file_cache_only) { + if (file_cache_only) { if (!accel_startup_ok || zps_api_failure_reason) { php_info_print_table_row(2, "Startup Failed", zps_api_failure_reason); } else { @@ -616,7 +616,7 @@ static ZEND_FUNCTION(opcache_get_status) if (ZCG(accel_directives).file_cache) { add_assoc_string(return_value, "file_cache", ZCG(accel_directives).file_cache); } - if (ZCG(accel_directives).file_cache_only) { + if (file_cache_only) { add_assoc_bool(return_value, "file_cache_only", 1); return; } diff --git a/ext/opcache/zend_file_cache.c b/ext/opcache/zend_file_cache.c index d27614b0de..3be1318f98 100644 --- a/ext/opcache/zend_file_cache.c +++ b/ext/opcache/zend_file_cache.c @@ -1388,7 +1388,7 @@ zend_persistent_script *zend_file_cache_script_load(zend_file_handle *file_handl return NULL; } - if (!ZCG(accel_directives).file_cache_only && + if (!file_cache_only && !ZCSG(restart_in_progress) && !ZSMMG(memory_exhausted) && accelerator_shm_read_lock() == SUCCESS) { diff --git a/ext/opcache/zend_persist.c b/ext/opcache/zend_persist.c index cb2d2812d8..b63b116510 100644 --- a/ext/opcache/zend_persist.c +++ b/ext/opcache/zend_persist.c @@ -35,7 +35,7 @@ #ifdef HAVE_OPCACHE_FILE_CACHE #define zend_set_str_gc_flags(str) do { \ - if (ZCG(accel_directives).file_cache_only) { \ + if (file_cache_only) { \ GC_FLAGS(str) = IS_STR_INTERNED; \ } else { \ GC_FLAGS(str) = IS_STR_INTERNED | IS_STR_PERMANENT; \ |