diff options
author | Dmitry Stogov <dmitry@zend.com> | 2017-12-28 14:08:12 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2017-12-28 14:08:12 +0300 |
commit | 60b2d67828185940b80e7923f0766fa22e6d5daa (patch) | |
tree | c9e4e3f6d76dcaacd1c4788a197fa2c03b448a3b /ext | |
parent | 7c96e974d912cfd019129e7d047dc5416fb43807 (diff) | |
download | php-git-60b2d67828185940b80e7923f0766fa22e6d5daa.tar.gz |
Fixed bug #75720 (File cache not populated after SHM runs full)
Diffstat (limited to 'ext')
-rw-r--r-- | ext/opcache/ZendAccelerator.c | 59 |
1 files changed, 40 insertions, 19 deletions
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 1c5b800c6b..b4033fb053 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -1214,19 +1214,10 @@ static void zend_accel_add_key(char *key, unsigned int key_length, zend_accel_ha } #ifdef HAVE_OPCACHE_FILE_CACHE -static zend_persistent_script *cache_script_in_file_cache(zend_persistent_script *new_persistent_script, int *from_shared_memory) +static zend_persistent_script *store_script_in_file_cache(zend_persistent_script *new_persistent_script) { uint memory_used; - /* Check if script may be stored in shared memory */ - if (!zend_accel_script_persistable(new_persistent_script)) { - return new_persistent_script; - } - - if (!zend_optimize_script(&new_persistent_script->script, ZCG(accel_directives).optimization_level, ZCG(accel_directives).opt_debug_level)) { - return new_persistent_script; - } - zend_shared_alloc_init_xlat_table(); /* Calculate the required memory size */ @@ -1266,9 +1257,23 @@ static zend_persistent_script *cache_script_in_file_cache(zend_persistent_script zend_file_cache_script_store(new_persistent_script, 0); - *from_shared_memory = 1; return new_persistent_script; } + +static zend_persistent_script *cache_script_in_file_cache(zend_persistent_script *new_persistent_script, int *from_shared_memory) +{ + /* Check if script may be stored in shared memory */ + if (!zend_accel_script_persistable(new_persistent_script)) { + return new_persistent_script; + } + + if (!zend_optimize_script(&new_persistent_script->script, ZCG(accel_directives).optimization_level, ZCG(accel_directives).opt_debug_level)) { + return new_persistent_script; + } + + *from_shared_memory = 1; + return store_script_in_file_cache(new_persistent_script); +} #endif static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_script *new_persistent_script, char *key, unsigned int key_length, int *from_shared_memory) @@ -1288,14 +1293,6 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr /* exclusive lock */ zend_shared_alloc_lock(); - if (zend_accel_hash_is_full(&ZCSG(hash))) { - zend_accel_error(ACCEL_LOG_DEBUG, "No more entries in hash table!"); - ZSMMG(memory_exhausted) = 1; - zend_accel_schedule_restart_if_necessary(ACCEL_RESTART_HASH); - zend_shared_alloc_unlock(); - return new_persistent_script; - } - /* Check if we still need to put the file into the cache (may be it was * already stored by another process. This final check is done under * exclusive lock) */ @@ -1314,6 +1311,19 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr } } + if (zend_accel_hash_is_full(&ZCSG(hash))) { + zend_accel_error(ACCEL_LOG_DEBUG, "No more entries in hash table!"); + ZSMMG(memory_exhausted) = 1; + zend_accel_schedule_restart_if_necessary(ACCEL_RESTART_HASH); + zend_shared_alloc_unlock(); +#ifdef HAVE_OPCACHE_FILE_CACHE + if (ZCG(accel_directives).file_cache) { + new_persistent_script = store_script_in_file_cache(new_persistent_script); + *from_shared_memory = 1; + } +#endif + return new_persistent_script; + } zend_shared_alloc_init_xlat_table(); @@ -1332,6 +1342,12 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr zend_shared_alloc_destroy_xlat_table(); zend_accel_schedule_restart_if_necessary(ACCEL_RESTART_OOM); zend_shared_alloc_unlock(); +#ifdef HAVE_OPCACHE_FILE_CACHE + if (ZCG(accel_directives).file_cache) { + new_persistent_script = store_script_in_file_cache(new_persistent_script); + *from_shared_memory = 1; + } +#endif return new_persistent_script; } @@ -1867,6 +1883,11 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type) if (ZSMMG(memory_exhausted) || ZCSG(restart_pending)) { SHM_PROTECT(); HANDLE_UNBLOCK_INTERRUPTIONS(); +#ifdef HAVE_OPCACHE_FILE_CACHE + if (ZCG(accel_directives).file_cache) { + return file_cache_compile_file(file_handle, type); + } +#endif return accelerator_orig_compile_file(file_handle, type); } |