Merge branch 'PHP-7.1' into PHP-7.2

* PHP-7.1:
  Fixed "opcache.file_cache_fallback" mode.
This commit is contained in:
Dmitry Stogov 2018-03-05 16:15:38 +03:00
commit a8fbb15311
6 changed files with 28 additions and 18 deletions

View File

@ -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
@ -432,7 +435,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
@ -1743,7 +1746,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)) ||
@ -2042,6 +2045,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)) {
@ -2173,7 +2179,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
@ -2632,7 +2638,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
@ -2664,6 +2671,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();
@ -2762,7 +2770,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();
@ -2774,10 +2782,10 @@ void accel_shutdown(void)
}
#ifdef HAVE_OPCACHE_FILE_CACHE
file_cache_only = ZCG(accel_directives).file_cache_only;
_file_cache_only = file_cache_only;
#endif
if (!file_cache_only && ZCG(accel_directives).interned_strings_buffer) {
if (!_file_cache_only && ZCG(accel_directives).interned_strings_buffer) {
accel_use_permanent_interned_strings();
}
@ -2785,7 +2793,7 @@ void accel_shutdown(void)
accel_free_ts_resources();
if (!file_cache_only) {
if (!_file_cache_only) {
zend_shared_alloc_shutdown();
}
zend_compile_file = accelerator_orig_compile_file;

View File

@ -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
@ -283,6 +285,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

View File

@ -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

View File

@ -405,7 +405,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;
}
@ -441,7 +441,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
@ -456,7 +456,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");
@ -466,7 +466,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 {
@ -615,7 +615,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;
}

View File

@ -1403,7 +1403,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) {

View File

@ -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; \