1
0
mirror of https://github.com/php/php-src.git synced 2026-04-21 23:18:13 +02:00

ext/opcache: merge redundant code and "bool" refactoring (#8237)

* ext/opcache/ZendAccelerator: make check_persistent_script_access() static

* ext/opcache/ZendAccelerator: convert "int" to "bool"

* ext/opcache/zend_file_cache: convert "int" to "bool"

* ext/opcache: use true/false for zend_persistent_script.corrupted

* ext/opcache/ZendAccelerator: move duplicate code to zend_accel_discard_script()

* ext/opcache/ZendAccelerator: convert accel_deactivate_now() to function

Simplify the #iddef ZEND_WIN32.

* ext/opcache/zend_file_cache: simplify iovec initializer

* ext/opcache/zend_file_cache: add local zend_string* variables

Eliminates lots of redundant casts and avoids reloading the variable
from RAM into registers.

* ext/opcache/zend_file_cache: use ZSTR_VAL()

* ext/opcache/zend_file_cache: move code to zend_file_cache_script_write()

This eliminates duplicate error handling code.
This commit is contained in:
Max Kellermann
2022-03-24 15:03:53 +01:00
committed by GitHub
parent 814374faa1
commit 04a4864b65
6 changed files with 228 additions and 224 deletions
+172 -170
View File
@@ -109,12 +109,12 @@ zend_accel_shared_globals *accel_shared_globals = NULL;
#ifdef ZEND_WIN32 #ifdef ZEND_WIN32
char accel_uname_id[32]; char accel_uname_id[32];
#endif #endif
bool accel_startup_ok = 0; bool accel_startup_ok = false;
static char *zps_failure_reason = NULL; static char *zps_failure_reason = NULL;
char *zps_api_failure_reason = NULL; char *zps_api_failure_reason = NULL;
bool file_cache_only = 0; /* process uses file cache only */ bool file_cache_only = false; /* process uses file cache only */
#if ENABLE_FILE_CACHE_FALLBACK #if ENABLE_FILE_CACHE_FALLBACK
bool fallback_process = 0; /* process uses file cache fallback */ bool fallback_process = false; /* process uses file cache fallback */
#endif #endif
static zend_op_array *(*accelerator_orig_compile_file)(zend_file_handle *file_handle, int type); static zend_op_array *(*accelerator_orig_compile_file)(zend_file_handle *file_handle, int type);
@@ -185,7 +185,7 @@ static time_t zend_accel_get_time(void)
# define zend_accel_get_time() time(NULL) # define zend_accel_get_time() time(NULL)
#endif #endif
static inline int is_stream_path(const char *filename) static inline bool is_stream_path(const char *filename)
{ {
const char *p; const char *p;
@@ -198,7 +198,7 @@ static inline int is_stream_path(const char *filename)
return ((p != filename) && (p[0] == ':') && (p[1] == '/') && (p[2] == '/')); return ((p != filename) && (p[0] == ':') && (p[1] == '/') && (p[2] == '/'));
} }
static inline int is_cacheable_stream_path(const char *filename) static inline bool is_cacheable_stream_path(const char *filename)
{ {
return memcmp(filename, "file://", sizeof("file://") - 1) == 0 || return memcmp(filename, "file://", sizeof("file://") - 1) == 0 ||
memcmp(filename, "phar://", sizeof("phar://") - 1) == 0; memcmp(filename, "phar://", sizeof("phar://") - 1) == 0;
@@ -225,7 +225,7 @@ static ZEND_FUNCTION(accel_chdir)
} }
} }
ZCG(cwd_key_len) = 0; ZCG(cwd_key_len) = 0;
ZCG(cwd_check) = 1; ZCG(cwd_check) = true;
} }
static inline zend_string* accel_getcwd(void) static inline zend_string* accel_getcwd(void)
@@ -240,7 +240,7 @@ static inline zend_string* accel_getcwd(void)
} }
ZCG(cwd) = zend_string_init(cwd, strlen(cwd), 0); ZCG(cwd) = zend_string_init(cwd, strlen(cwd), 0);
ZCG(cwd_key_len) = 0; ZCG(cwd_key_len) = 0;
ZCG(cwd_check) = 1; ZCG(cwd_check) = true;
return ZCG(cwd); return ZCG(cwd);
} }
} }
@@ -264,7 +264,7 @@ static ZEND_INI_MH(accel_include_path_on_modify)
if (ret == SUCCESS) { if (ret == SUCCESS) {
ZCG(include_path) = new_value; ZCG(include_path) = new_value;
ZCG(include_path_key_len) = 0; ZCG(include_path_key_len) = 0;
ZCG(include_path_check) = 1; ZCG(include_path_check) = true;
} }
return ret; return ret;
} }
@@ -285,13 +285,13 @@ static inline void accel_restart_enter(void)
zend_accel_error(ACCEL_LOG_DEBUG, "RestartC(+1): %s (%d)", strerror(errno), errno); zend_accel_error(ACCEL_LOG_DEBUG, "RestartC(+1): %s (%d)", strerror(errno), errno);
} }
#endif #endif
ZCSG(restart_in_progress) = 1; ZCSG(restart_in_progress) = true;
} }
static inline void accel_restart_leave(void) static inline void accel_restart_leave(void)
{ {
#ifdef ZEND_WIN32 #ifdef ZEND_WIN32
ZCSG(restart_in_progress) = 0; ZCSG(restart_in_progress) = false;
DECREMENT(restart_in); DECREMENT(restart_in);
#else #else
struct flock restart_finished; struct flock restart_finished;
@@ -301,7 +301,7 @@ static inline void accel_restart_leave(void)
restart_finished.l_start = 2; restart_finished.l_start = 2;
restart_finished.l_len = 1; restart_finished.l_len = 1;
ZCSG(restart_in_progress) = 0; ZCSG(restart_in_progress) = false;
if (fcntl(lock_file, F_SETLK, &restart_finished) == -1) { if (fcntl(lock_file, F_SETLK, &restart_finished) == -1) {
zend_accel_error(ACCEL_LOG_DEBUG, "RestartC(-1): %s (%d)", strerror(errno), errno); zend_accel_error(ACCEL_LOG_DEBUG, "RestartC(-1): %s (%d)", strerror(errno), errno);
} }
@@ -324,7 +324,7 @@ static inline int accel_restart_is_active(void)
return FAILURE; return FAILURE;
} }
if (restart_check.l_type == F_UNLCK) { if (restart_check.l_type == F_UNLCK) {
ZCSG(restart_in_progress) = 0; ZCSG(restart_in_progress) = false;
return 0; return 0;
} else { } else {
return 1; return 1;
@@ -366,7 +366,7 @@ static inline void accel_deactivate_sub(void)
if (ZCG(counted)) { if (ZCG(counted)) {
SHM_UNPROTECT(); SHM_UNPROTECT();
DECREMENT(mem_usage); DECREMENT(mem_usage);
ZCG(counted) = 0; ZCG(counted) = false;
SHM_PROTECT(); SHM_PROTECT();
} }
#else #else
@@ -484,7 +484,7 @@ static zend_always_inline zend_string *accel_find_interned_string(zend_string *s
if (!ZCG(accelerator_enabled) || accel_activate_add() == FAILURE) { if (!ZCG(accelerator_enabled) || accel_activate_add() == FAILURE) {
return NULL; return NULL;
} }
ZCG(counted) = 1; ZCG(counted) = true;
} }
h = zend_string_hash_val(str); h = zend_string_hash_val(str);
@@ -802,9 +802,9 @@ static void accel_use_shm_interned_strings(void)
if (ZCSG(interned_strings).saved_top == NULL) { if (ZCSG(interned_strings).saved_top == NULL) {
accel_copy_permanent_strings(accel_new_interned_string); accel_copy_permanent_strings(accel_new_interned_string);
} else { } else {
ZCG(counted) = 1; ZCG(counted) = true;
accel_copy_permanent_strings(accel_replace_string_by_shm_permanent); accel_copy_permanent_strings(accel_replace_string_by_shm_permanent);
ZCG(counted) = 0; ZCG(counted) = false;
} }
accel_interned_strings_save_state(); accel_interned_strings_save_state();
@@ -816,14 +816,14 @@ static void accel_use_shm_interned_strings(void)
#ifndef ZEND_WIN32 #ifndef ZEND_WIN32
static inline void kill_all_lockers(struct flock *mem_usage_check) static inline void kill_all_lockers(struct flock *mem_usage_check)
{ {
int success, tries; int tries;
/* so that other process won't try to force while we are busy cleaning up */ /* so that other process won't try to force while we are busy cleaning up */
ZCSG(force_restart_time) = 0; ZCSG(force_restart_time) = 0;
while (mem_usage_check->l_pid > 0) { while (mem_usage_check->l_pid > 0) {
/* Try SIGTERM first, switch to SIGKILL if not successful. */ /* Try SIGTERM first, switch to SIGKILL if not successful. */
int signal = SIGTERM; int signal = SIGTERM;
errno = 0; errno = 0;
success = 0; bool success = false;
tries = 10; tries = 10;
while (tries--) { while (tries--) {
@@ -831,7 +831,7 @@ static inline void kill_all_lockers(struct flock *mem_usage_check)
if (kill(mem_usage_check->l_pid, signal)) { if (kill(mem_usage_check->l_pid, signal)) {
if (errno == ESRCH) { if (errno == ESRCH) {
/* Process died before the signal was sent */ /* Process died before the signal was sent */
success = 1; success = true;
zend_accel_error(ACCEL_LOG_WARNING, "Process %d died before SIGKILL was sent", mem_usage_check->l_pid); zend_accel_error(ACCEL_LOG_WARNING, "Process %d died before SIGKILL was sent", mem_usage_check->l_pid);
} else if (errno != 0) { } else if (errno != 0) {
zend_accel_error(ACCEL_LOG_WARNING, "Failed to send SIGKILL to locker %d: %s", mem_usage_check->l_pid, strerror(errno)); zend_accel_error(ACCEL_LOG_WARNING, "Failed to send SIGKILL to locker %d: %s", mem_usage_check->l_pid, strerror(errno));
@@ -843,7 +843,7 @@ static inline void kill_all_lockers(struct flock *mem_usage_check)
if (kill(mem_usage_check->l_pid, 0)) { if (kill(mem_usage_check->l_pid, 0)) {
if (errno == ESRCH) { if (errno == ESRCH) {
/* successfully killed locker, process no longer exists */ /* successfully killed locker, process no longer exists */
success = 1; success = true;
zend_accel_error(ACCEL_LOG_WARNING, "Killed locker %d", mem_usage_check->l_pid); zend_accel_error(ACCEL_LOG_WARNING, "Killed locker %d", mem_usage_check->l_pid);
} else if (errno != 0) { } else if (errno != 0) {
zend_accel_error(ACCEL_LOG_WARNING, "Failed to check locker %d: %s", mem_usage_check->l_pid, strerror(errno)); zend_accel_error(ACCEL_LOG_WARNING, "Failed to check locker %d: %s", mem_usage_check->l_pid, strerror(errno));
@@ -1211,7 +1211,7 @@ zend_string *accel_make_persistent_key(zend_string *str)
cwd = ZSTR_VAL(cwd_str); cwd = ZSTR_VAL(cwd_str);
cwd_len = ZSTR_LEN(cwd_str); cwd_len = ZSTR_LEN(cwd_str);
if (ZCG(cwd_check)) { if (ZCG(cwd_check)) {
ZCG(cwd_check) = 0; ZCG(cwd_check) = false;
if (ZCG(accelerator_enabled)) { if (ZCG(accelerator_enabled)) {
zend_string *str = accel_find_interned_string(cwd_str); zend_string *str = accel_find_interned_string(cwd_str);
@@ -1255,7 +1255,7 @@ zend_string *accel_make_persistent_key(zend_string *str)
include_path_len = ZSTR_LEN(ZCG(include_path)); include_path_len = ZSTR_LEN(ZCG(include_path));
if (ZCG(include_path_check)) { if (ZCG(include_path_check)) {
ZCG(include_path_check) = 0; ZCG(include_path_check) = false;
if (ZCG(accelerator_enabled)) { if (ZCG(accelerator_enabled)) {
zend_string *str = accel_find_interned_string(ZCG(include_path)); zend_string *str = accel_find_interned_string(ZCG(include_path));
@@ -1342,6 +1342,40 @@ zend_string *accel_make_persistent_key(zend_string *str)
return str; return str;
} }
/**
* Discard a #zend_persistent_script currently stored in shared
* memory.
*
* Caller must lock shared memory via zend_shared_alloc_lock().
*/
static void zend_accel_discard_script(zend_persistent_script *persistent_script)
{
if (persistent_script->corrupted) {
/* already discarded */
return;
}
persistent_script->corrupted = true;
persistent_script->timestamp = 0;
ZSMMG(wasted_shared_memory) += persistent_script->dynamic_members.memory_consumption;
if (ZSMMG(memory_exhausted)) {
zend_accel_restart_reason reason =
zend_accel_hash_is_full(&ZCSG(hash)) ? ACCEL_RESTART_HASH : ACCEL_RESTART_OOM;
zend_accel_schedule_restart_if_necessary(reason);
}
}
/**
* Wrapper for zend_accel_discard_script() which locks shared memory
* via zend_shared_alloc_lock().
*/
static void zend_accel_lock_discard_script(zend_persistent_script *persistent_script)
{
zend_shared_alloc_lock();
zend_accel_discard_script(persistent_script);
zend_shared_alloc_unlock();
}
int zend_accel_invalidate(zend_string *filename, bool force) int zend_accel_invalidate(zend_string *filename, bool force)
{ {
zend_string *realpath; zend_string *realpath;
@@ -1372,18 +1406,7 @@ int zend_accel_invalidate(zend_string *filename, bool force)
do_validate_timestamps(persistent_script, &file_handle) == FAILURE) { do_validate_timestamps(persistent_script, &file_handle) == FAILURE) {
HANDLE_BLOCK_INTERRUPTIONS(); HANDLE_BLOCK_INTERRUPTIONS();
SHM_UNPROTECT(); SHM_UNPROTECT();
zend_shared_alloc_lock(); zend_accel_lock_discard_script(persistent_script);
if (!persistent_script->corrupted) {
persistent_script->corrupted = 1;
persistent_script->timestamp = 0;
ZSMMG(wasted_shared_memory) += persistent_script->dynamic_members.memory_consumption;
if (ZSMMG(memory_exhausted)) {
zend_accel_restart_reason reason =
zend_accel_hash_is_full(&ZCSG(hash)) ? ACCEL_RESTART_HASH : ACCEL_RESTART_OOM;
zend_accel_schedule_restart_if_necessary(reason);
}
}
zend_shared_alloc_unlock();
SHM_PROTECT(); SHM_PROTECT();
HANDLE_UNBLOCK_INTERRUPTIONS(); HANDLE_UNBLOCK_INTERRUPTIONS();
} }
@@ -1427,7 +1450,7 @@ static void zend_accel_add_key(zend_string *key, zend_accel_hash_entry *bucket)
if (!zend_accel_hash_find(&ZCSG(hash), key)) { if (!zend_accel_hash_find(&ZCSG(hash), key)) {
if (zend_accel_hash_is_full(&ZCSG(hash))) { if (zend_accel_hash_is_full(&ZCSG(hash))) {
zend_accel_error(ACCEL_LOG_DEBUG, "No more entries in hash table!"); zend_accel_error(ACCEL_LOG_DEBUG, "No more entries in hash table!");
ZSMMG(memory_exhausted) = 1; ZSMMG(memory_exhausted) = true;
zend_accel_schedule_restart_if_necessary(ACCEL_RESTART_HASH); zend_accel_schedule_restart_if_necessary(ACCEL_RESTART_HASH);
} else { } else {
zend_string *new_key = accel_new_interned_key(key); zend_string *new_key = accel_new_interned_key(key);
@@ -1493,12 +1516,12 @@ static zend_persistent_script *store_script_in_file_cache(zend_persistent_script
new_persistent_script->dynamic_members.checksum = zend_accel_script_checksum(new_persistent_script); new_persistent_script->dynamic_members.checksum = zend_accel_script_checksum(new_persistent_script);
zend_file_cache_script_store(new_persistent_script, 0); zend_file_cache_script_store(new_persistent_script, /* is_shm */ false);
return new_persistent_script; return new_persistent_script;
} }
static zend_persistent_script *cache_script_in_file_cache(zend_persistent_script *new_persistent_script, int *from_shared_memory) static zend_persistent_script *cache_script_in_file_cache(zend_persistent_script *new_persistent_script, bool *from_shared_memory)
{ {
uint32_t orig_compiler_options; uint32_t orig_compiler_options;
@@ -1508,11 +1531,11 @@ static zend_persistent_script *cache_script_in_file_cache(zend_persistent_script
zend_accel_finalize_delayed_early_binding_list(new_persistent_script); zend_accel_finalize_delayed_early_binding_list(new_persistent_script);
CG(compiler_options) = orig_compiler_options; CG(compiler_options) = orig_compiler_options;
*from_shared_memory = 1; *from_shared_memory = true;
return store_script_in_file_cache(new_persistent_script); return store_script_in_file_cache(new_persistent_script);
} }
static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_script *new_persistent_script, zend_string *key, int *from_shared_memory) static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_script *new_persistent_script, zend_string *key, bool *from_shared_memory)
{ {
zend_accel_hash_entry *bucket; zend_accel_hash_entry *bucket;
uint32_t memory_used; uint32_t memory_used;
@@ -1546,7 +1569,7 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr
#if 1 #if 1
/* prefer the script already stored in SHM */ /* prefer the script already stored in SHM */
free_persistent_script(new_persistent_script, 1); free_persistent_script(new_persistent_script, 1);
*from_shared_memory = 1; *from_shared_memory = true;
return existing_persistent_script; return existing_persistent_script;
#else #else
return new_persistent_script; return new_persistent_script;
@@ -1556,12 +1579,12 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr
if (zend_accel_hash_is_full(&ZCSG(hash))) { if (zend_accel_hash_is_full(&ZCSG(hash))) {
zend_accel_error(ACCEL_LOG_DEBUG, "No more entries in hash table!"); zend_accel_error(ACCEL_LOG_DEBUG, "No more entries in hash table!");
ZSMMG(memory_exhausted) = 1; ZSMMG(memory_exhausted) = true;
zend_accel_schedule_restart_if_necessary(ACCEL_RESTART_HASH); zend_accel_schedule_restart_if_necessary(ACCEL_RESTART_HASH);
zend_shared_alloc_unlock(); zend_shared_alloc_unlock();
if (ZCG(accel_directives).file_cache) { if (ZCG(accel_directives).file_cache) {
new_persistent_script = store_script_in_file_cache(new_persistent_script); new_persistent_script = store_script_in_file_cache(new_persistent_script);
*from_shared_memory = 1; *from_shared_memory = true;
} }
return new_persistent_script; return new_persistent_script;
} }
@@ -1579,7 +1602,7 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr
zend_shared_alloc_unlock(); zend_shared_alloc_unlock();
if (ZCG(accel_directives).file_cache) { if (ZCG(accel_directives).file_cache) {
new_persistent_script = store_script_in_file_cache(new_persistent_script); new_persistent_script = store_script_in_file_cache(new_persistent_script);
*from_shared_memory = 1; *from_shared_memory = true;
} }
return new_persistent_script; return new_persistent_script;
} }
@@ -1624,7 +1647,7 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr
zend_accel_error(ACCEL_LOG_INFO, "Added key '%s'", ZSTR_VAL(key)); zend_accel_error(ACCEL_LOG_INFO, "Added key '%s'", ZSTR_VAL(key));
} else { } else {
zend_accel_error(ACCEL_LOG_DEBUG, "No more entries in hash table!"); zend_accel_error(ACCEL_LOG_DEBUG, "No more entries in hash table!");
ZSMMG(memory_exhausted) = 1; ZSMMG(memory_exhausted) = true;
zend_accel_schedule_restart_if_necessary(ACCEL_RESTART_HASH); zend_accel_schedule_restart_if_necessary(ACCEL_RESTART_HASH);
} }
} else { } else {
@@ -1639,11 +1662,11 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr
if (ZCG(accel_directives).file_cache) { if (ZCG(accel_directives).file_cache) {
SHM_PROTECT(); SHM_PROTECT();
zend_file_cache_script_store(new_persistent_script, 1); zend_file_cache_script_store(new_persistent_script, /* is_shm */ true);
SHM_UNPROTECT(); SHM_UNPROTECT();
} }
*from_shared_memory = 1; *from_shared_memory = true;
return new_persistent_script; return new_persistent_script;
} }
@@ -1694,7 +1717,7 @@ static zend_persistent_script *opcache_compile_file(zend_file_handle *file_handl
zend_op_array *orig_active_op_array; zend_op_array *orig_active_op_array;
zval orig_user_error_handler; zval orig_user_error_handler;
zend_op_array *op_array; zend_op_array *op_array;
int do_bailout = 0; bool do_bailout = false;
accel_time_t timestamp = 0; accel_time_t timestamp = 0;
uint32_t orig_compiler_options = 0; uint32_t orig_compiler_options = 0;
@@ -1782,7 +1805,7 @@ static zend_persistent_script *opcache_compile_file(zend_file_handle *file_handl
CG(compiler_options) = orig_compiler_options; CG(compiler_options) = orig_compiler_options;
} zend_catch { } zend_catch {
op_array = NULL; op_array = NULL;
do_bailout = 1; do_bailout = true;
CG(compiler_options) = orig_compiler_options; CG(compiler_options) = orig_compiler_options;
} zend_end_try(); } zend_end_try();
@@ -1845,7 +1868,7 @@ zend_op_array *file_cache_compile_file(zend_file_handle *file_handle, int type)
{ {
zend_persistent_script *persistent_script; zend_persistent_script *persistent_script;
zend_op_array *op_array = NULL; zend_op_array *op_array = NULL;
int from_memory; /* if the script we've got is stored in SHM */ bool from_memory; /* if the script we've got is stored in SHM */
if (is_stream_path(ZSTR_VAL(file_handle->filename)) && if (is_stream_path(ZSTR_VAL(file_handle->filename)) &&
!is_cacheable_stream_path(ZSTR_VAL(file_handle->filename))) { !is_cacheable_stream_path(ZSTR_VAL(file_handle->filename))) {
@@ -1906,7 +1929,7 @@ zend_op_array *file_cache_compile_file(zend_file_handle *file_handle, int type)
persistent_script = opcache_compile_file(file_handle, type, &op_array); persistent_script = opcache_compile_file(file_handle, type, &op_array);
if (persistent_script) { if (persistent_script) {
from_memory = 0; from_memory = false;
persistent_script = cache_script_in_file_cache(persistent_script, &from_memory); persistent_script = cache_script_in_file_cache(persistent_script, &from_memory);
return zend_accel_load_script(persistent_script, from_memory); return zend_accel_load_script(persistent_script, from_memory);
} }
@@ -1914,10 +1937,9 @@ zend_op_array *file_cache_compile_file(zend_file_handle *file_handle, int type)
return op_array; return op_array;
} }
int check_persistent_script_access(zend_persistent_script *persistent_script) static int check_persistent_script_access(zend_persistent_script *persistent_script)
{ {
char *phar_path, *ptr; char *phar_path, *ptr;
int ret;
if ((ZSTR_LEN(persistent_script->script.filename)<sizeof("phar://.phar")) || if ((ZSTR_LEN(persistent_script->script.filename)<sizeof("phar://.phar")) ||
memcmp(ZSTR_VAL(persistent_script->script.filename), "phar://", sizeof("phar://")-1)) { memcmp(ZSTR_VAL(persistent_script->script.filename), "phar://", sizeof("phar://")-1)) {
@@ -1930,7 +1952,7 @@ int check_persistent_script_access(zend_persistent_script *persistent_script)
{ {
*(ptr+sizeof(".phar/")-2) = 0; /* strip path inside .phar file */ *(ptr+sizeof(".phar/")-2) = 0; /* strip path inside .phar file */
} }
ret = access(phar_path, R_OK) != 0; bool ret = access(phar_path, R_OK) != 0;
efree(phar_path); efree(phar_path);
return ret; return ret;
} }
@@ -1941,7 +1963,7 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
{ {
zend_persistent_script *persistent_script = NULL; zend_persistent_script *persistent_script = NULL;
zend_string *key = NULL; zend_string *key = NULL;
int from_shared_memory; /* if the script we've got is stored in SHM */ bool from_shared_memory; /* if the script we've got is stored in SHM */
if (!file_handle->filename || !ZCG(accelerator_enabled)) { if (!file_handle->filename || !ZCG(accelerator_enabled)) {
/* The Accelerator is disabled, act as if without the Accelerator */ /* The Accelerator is disabled, act as if without the Accelerator */
@@ -2055,7 +2077,7 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
} }
return accelerator_orig_compile_file(file_handle, type); return accelerator_orig_compile_file(file_handle, type);
} }
ZCG(counted) = 1; ZCG(counted) = true;
} }
/* Revalidate accessibility of cached file */ /* Revalidate accessibility of cached file */
@@ -2079,18 +2101,7 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
/* If script is found then validate_timestamps if option is enabled */ /* If script is found then validate_timestamps if option is enabled */
if (persistent_script && ZCG(accel_directives).validate_timestamps) { if (persistent_script && ZCG(accel_directives).validate_timestamps) {
if (validate_timestamp_and_record(persistent_script, file_handle) == FAILURE) { if (validate_timestamp_and_record(persistent_script, file_handle) == FAILURE) {
zend_shared_alloc_lock(); zend_accel_lock_discard_script(persistent_script);
if (!persistent_script->corrupted) {
persistent_script->corrupted = 1;
persistent_script->timestamp = 0;
ZSMMG(wasted_shared_memory) += persistent_script->dynamic_members.memory_consumption;
if (ZSMMG(memory_exhausted)) {
zend_accel_restart_reason reason =
zend_accel_hash_is_full(&ZCSG(hash)) ? ACCEL_RESTART_HASH : ACCEL_RESTART_OOM;
zend_accel_schedule_restart_if_necessary(reason);
}
}
zend_shared_alloc_unlock();
persistent_script = NULL; persistent_script = NULL;
} }
} }
@@ -2104,18 +2115,7 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
/* The checksum is wrong */ /* The checksum is wrong */
zend_accel_error(ACCEL_LOG_INFO, "Checksum failed for '%s': expected=0x%08x, found=0x%08x", zend_accel_error(ACCEL_LOG_INFO, "Checksum failed for '%s': expected=0x%08x, found=0x%08x",
ZSTR_VAL(persistent_script->script.filename), persistent_script->dynamic_members.checksum, checksum); ZSTR_VAL(persistent_script->script.filename), persistent_script->dynamic_members.checksum, checksum);
zend_shared_alloc_lock(); zend_accel_lock_discard_script(persistent_script);
if (!persistent_script->corrupted) {
persistent_script->corrupted = 1;
persistent_script->timestamp = 0;
ZSMMG(wasted_shared_memory) += persistent_script->dynamic_members.memory_consumption;
if (ZSMMG(memory_exhausted)) {
zend_accel_restart_reason reason =
zend_accel_hash_is_full(&ZCSG(hash)) ? ACCEL_RESTART_HASH : ACCEL_RESTART_OOM;
zend_accel_schedule_restart_if_necessary(reason);
}
}
zend_shared_alloc_unlock();
persistent_script = NULL; persistent_script = NULL;
} }
} }
@@ -2152,7 +2152,7 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
/* Try and cache the script and assume that it is returned from_shared_memory. /* Try and cache the script and assume that it is returned from_shared_memory.
* If it isn't compile_and_cache_file() changes the flag to 0 * If it isn't compile_and_cache_file() changes the flag to 0
*/ */
from_shared_memory = 0; from_shared_memory = false;
if (persistent_script) { if (persistent_script) {
persistent_script = cache_script_in_shared_memory(persistent_script, key, &from_shared_memory); persistent_script = cache_script_in_shared_memory(persistent_script, key, &from_shared_memory);
} }
@@ -2217,7 +2217,7 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
HANDLE_UNBLOCK_INTERRUPTIONS(); HANDLE_UNBLOCK_INTERRUPTIONS();
replay_warnings(persistent_script->num_warnings, persistent_script->warnings); replay_warnings(persistent_script->num_warnings, persistent_script->warnings);
from_shared_memory = 1; from_shared_memory = true;
} }
/* Fetch jit auto globals used in the script before execution */ /* Fetch jit auto globals used in the script before execution */
@@ -2236,15 +2236,15 @@ static zend_always_inline zend_inheritance_cache_entry* zend_accel_inheritance_c
ZEND_ASSERT(!(ce->ce_flags & ZEND_ACC_LINKED)); ZEND_ASSERT(!(ce->ce_flags & ZEND_ACC_LINKED));
while (entry) { while (entry) {
bool found = 1; bool found = true;
bool needs_autoload = 0; bool needs_autoload = false;
if (entry->parent != parent) { if (entry->parent != parent) {
found = 0; found = false;
} else { } else {
for (i = 0; i < ce->num_traits + ce->num_interfaces; i++) { for (i = 0; i < ce->num_traits + ce->num_interfaces; i++) {
if (entry->traits_and_interfaces[i] != traits_and_interfaces[i]) { if (entry->traits_and_interfaces[i] != traits_and_interfaces[i]) {
found = 0; found = false;
break; break;
} }
} }
@@ -2254,9 +2254,9 @@ static zend_always_inline zend_inheritance_cache_entry* zend_accel_inheritance_c
if (ce != entry->dependencies[i].ce) { if (ce != entry->dependencies[i].ce) {
if (!ce) { if (!ce) {
needs_autoload = 1; needs_autoload = true;
} else { } else {
found = 0; found = false;
break; break;
} }
} }
@@ -2572,12 +2572,12 @@ static zend_string* persistent_zend_resolve_path(zend_string *filename)
static void zend_reset_cache_vars(void) static void zend_reset_cache_vars(void)
{ {
ZSMMG(memory_exhausted) = 0; ZSMMG(memory_exhausted) = false;
ZCSG(hits) = 0; ZCSG(hits) = 0;
ZCSG(misses) = 0; ZCSG(misses) = 0;
ZCSG(blacklist_misses) = 0; ZCSG(blacklist_misses) = 0;
ZSMMG(wasted_shared_memory) = 0; ZSMMG(wasted_shared_memory) = 0;
ZCSG(restart_pending) = 0; ZCSG(restart_pending) = false;
ZCSG(force_restart_time) = 0; ZCSG(force_restart_time) = 0;
ZCSG(map_ptr_last) = CG(map_ptr_last); ZCSG(map_ptr_last) = CG(map_ptr_last);
} }
@@ -2602,7 +2602,7 @@ static void accel_reset_pcre_cache(void)
zend_result accel_activate(INIT_FUNC_ARGS) zend_result accel_activate(INIT_FUNC_ARGS)
{ {
if (!ZCG(enabled) || !accel_startup_ok) { if (!ZCG(enabled) || !accel_startup_ok) {
ZCG(accelerator_enabled) = 0; ZCG(accelerator_enabled) = false;
return SUCCESS; return SUCCESS;
} }
@@ -2612,14 +2612,14 @@ zend_result accel_activate(INIT_FUNC_ARGS)
ZCG(cache_opline) = NULL; ZCG(cache_opline) = NULL;
ZCG(cache_persistent_script) = NULL; ZCG(cache_persistent_script) = NULL;
ZCG(include_path_key_len) = 0; ZCG(include_path_key_len) = 0;
ZCG(include_path_check) = 1; ZCG(include_path_check) = true;
ZCG(cwd) = NULL; ZCG(cwd) = NULL;
ZCG(cwd_key_len) = 0; ZCG(cwd_key_len) = 0;
ZCG(cwd_check) = 1; ZCG(cwd_check) = true;
if (file_cache_only) { if (file_cache_only) {
ZCG(accelerator_enabled) = 0; ZCG(accelerator_enabled) = false;
return SUCCESS; return SUCCESS;
} }
@@ -2656,15 +2656,15 @@ zend_result accel_activate(INIT_FUNC_ARGS)
zend_accel_error(ACCEL_LOG_WARNING, "Stuck count for pid %d", getpid()); zend_accel_error(ACCEL_LOG_WARNING, "Stuck count for pid %d", getpid());
#endif #endif
accel_unlock_all(); accel_unlock_all();
ZCG(counted) = 0; ZCG(counted) = false;
} }
if (ZCSG(restart_pending)) { if (ZCSG(restart_pending)) {
zend_shared_alloc_lock(); zend_shared_alloc_lock();
if (ZCSG(restart_pending) != 0) { /* check again, to ensure that the cache wasn't already cleaned by another process */ if (ZCSG(restart_pending)) { /* check again, to ensure that the cache wasn't already cleaned by another process */
if (accel_is_inactive() == SUCCESS) { if (accel_is_inactive() == SUCCESS) {
zend_accel_error(ACCEL_LOG_DEBUG, "Restarting!"); zend_accel_error(ACCEL_LOG_DEBUG, "Restarting!");
ZCSG(restart_pending) = 0; ZCSG(restart_pending) = false;
switch ZCSG(restart_reason) { switch ZCSG(restart_reason) {
case ACCEL_RESTART_OOM: case ACCEL_RESTART_OOM:
ZCSG(oom_restarts)++; ZCSG(oom_restarts)++;
@@ -2720,10 +2720,10 @@ zend_result accel_activate(INIT_FUNC_ARGS)
realpath_cache_clean(); realpath_cache_clean();
accel_reset_pcre_cache(); accel_reset_pcre_cache();
ZCG(pcre_reseted) = 0; ZCG(pcre_reseted) = false;
} else if (!ZCG(accelerator_enabled) && !ZCG(pcre_reseted)) { } else if (!ZCG(accelerator_enabled) && !ZCG(pcre_reseted)) {
accel_reset_pcre_cache(); accel_reset_pcre_cache();
ZCG(pcre_reseted) = 1; ZCG(pcre_reseted) = true;
} }
@@ -2758,7 +2758,7 @@ zend_result accel_post_deactivate(void)
zend_shared_alloc_safe_unlock(); /* be sure we didn't leave cache locked */ zend_shared_alloc_safe_unlock(); /* be sure we didn't leave cache locked */
accel_unlock_all(); accel_unlock_all();
ZCG(counted) = 0; ZCG(counted) = false;
return SUCCESS; return SUCCESS;
} }
@@ -2788,7 +2788,7 @@ static int accelerator_remove_cb(zend_extension *element1, zend_extension *eleme
static void zps_startup_failure(char *reason, char *api_reason, int (*cb)(zend_extension *, zend_extension *)) static void zps_startup_failure(char *reason, char *api_reason, int (*cb)(zend_extension *, zend_extension *))
{ {
accel_startup_ok = 0; accel_startup_ok = false;
zps_failure_reason = reason; zps_failure_reason = reason;
zps_api_failure_reason = api_reason?api_reason:reason; zps_api_failure_reason = api_reason?api_reason:reason;
zend_llist_del_element(&zend_extensions, NULL, (int (*)(void *, void *))cb); zend_llist_del_element(&zend_extensions, NULL, (int (*)(void *, void *))cb);
@@ -2896,10 +2896,10 @@ static int zend_accel_init_shm(void)
ZCSG(hash_restarts) = 0; ZCSG(hash_restarts) = 0;
ZCSG(manual_restarts) = 0; ZCSG(manual_restarts) = 0;
ZCSG(accelerator_enabled) = 1; ZCSG(accelerator_enabled) = true;
ZCSG(start_time) = zend_accel_get_time(); ZCSG(start_time) = zend_accel_get_time();
ZCSG(last_restart_time) = 0; ZCSG(last_restart_time) = 0;
ZCSG(restart_in_progress) = 0; ZCSG(restart_in_progress) = false;
for (i = 0; i < -HT_MIN_MASK; i++) { for (i = 0; i < -HT_MIN_MASK; i++) {
ZCSG(uninitialized_bucket)[i] = HT_INVALID_IDX; ZCSG(uninitialized_bucket)[i] = HT_INVALID_IDX;
@@ -3103,7 +3103,7 @@ static int accel_startup(zend_extension *extension)
#endif #endif
if (start_accel_module() == FAILURE) { if (start_accel_module() == FAILURE) {
accel_startup_ok = 0; accel_startup_ok = false;
zend_error(E_WARNING, ACCELERATOR_PRODUCT_NAME ": module registration failed!"); zend_error(E_WARNING, ACCELERATOR_PRODUCT_NAME ": module registration failed!");
return FAILURE; return FAILURE;
} }
@@ -3127,7 +3127,7 @@ static int accel_startup(zend_extension *extension)
/* no supported SAPI found - disable acceleration and stop initialization */ /* no supported SAPI found - disable acceleration and stop initialization */
if (accel_find_sapi() == FAILURE) { if (accel_find_sapi() == FAILURE) {
accel_startup_ok = 0; accel_startup_ok = false;
if (!ZCG(accel_directives).enable_cli && if (!ZCG(accel_directives).enable_cli &&
strcmp(sapi_module.name, "cli") == 0) { strcmp(sapi_module.name, "cli") == 0) {
zps_startup_failure("Opcode Caching is disabled for CLI", NULL, accelerator_remove_cb); zps_startup_failure("Opcode Caching is disabled for CLI", NULL, accelerator_remove_cb);
@@ -3172,7 +3172,7 @@ static zend_result accel_post_startup(void)
size_t shm_size = ZCG(accel_directives).memory_consumption; size_t shm_size = ZCG(accel_directives).memory_consumption;
#ifdef HAVE_JIT #ifdef HAVE_JIT
size_t jit_size = 0; size_t jit_size = 0;
bool reattached = 0; bool reattached = false;
if (JIT_G(enabled) && JIT_G(buffer_size) if (JIT_G(enabled) && JIT_G(buffer_size)
&& zend_jit_check_support() == SUCCESS) { && zend_jit_check_support() == SUCCESS) {
@@ -3194,17 +3194,17 @@ static zend_result accel_post_startup(void)
#endif #endif
case ALLOC_SUCCESS: case ALLOC_SUCCESS:
if (zend_accel_init_shm() == FAILURE) { if (zend_accel_init_shm() == FAILURE) {
accel_startup_ok = 0; accel_startup_ok = false;
return FAILURE; return FAILURE;
} }
break; break;
case ALLOC_FAILURE: case ALLOC_FAILURE:
accel_startup_ok = 0; accel_startup_ok = false;
zend_accel_error_noreturn(ACCEL_LOG_FATAL, "Failure to initialize shared memory structures - probably not enough shared memory."); zend_accel_error_noreturn(ACCEL_LOG_FATAL, "Failure to initialize shared memory structures - probably not enough shared memory.");
return SUCCESS; return SUCCESS;
case SUCCESSFULLY_REATTACHED: case SUCCESSFULLY_REATTACHED:
#ifdef HAVE_JIT #ifdef HAVE_JIT
reattached = 1; reattached = true;
#endif #endif
zend_shared_alloc_lock(); zend_shared_alloc_lock();
accel_shared_globals = (zend_accel_shared_globals *) ZSMMG(app_shared_globals); accel_shared_globals = (zend_accel_shared_globals *) ZSMMG(app_shared_globals);
@@ -3215,15 +3215,15 @@ static zend_result accel_post_startup(void)
zend_shared_alloc_unlock(); zend_shared_alloc_unlock();
break; break;
case FAILED_REATTACHED: case FAILED_REATTACHED:
accel_startup_ok = 0; accel_startup_ok = false;
zend_accel_error_noreturn(ACCEL_LOG_FATAL, "Failure to initialize shared memory structures - cannot reattach to exiting shared memory."); zend_accel_error_noreturn(ACCEL_LOG_FATAL, "Failure to initialize shared memory structures - cannot reattach to exiting shared memory.");
return SUCCESS; return SUCCESS;
break; break;
#if ENABLE_FILE_CACHE_FALLBACK #if ENABLE_FILE_CACHE_FALLBACK
case ALLOC_FALLBACK: case ALLOC_FALLBACK:
zend_shared_alloc_lock(); zend_shared_alloc_lock();
file_cache_only = 1; file_cache_only = true;
fallback_process = 1; fallback_process = true;
zend_shared_alloc_unlock(); zend_shared_alloc_unlock();
goto file_cache_fallback; goto file_cache_fallback;
break; break;
@@ -3241,8 +3241,8 @@ static zend_result accel_post_startup(void)
if (JIT_G(buffer_size) == 0 if (JIT_G(buffer_size) == 0
|| !ZSMMG(reserved) || !ZSMMG(reserved)
|| zend_jit_startup(ZSMMG(reserved), jit_size, reattached) != SUCCESS) { || zend_jit_startup(ZSMMG(reserved), jit_size, reattached) != SUCCESS) {
JIT_G(enabled) = 0; JIT_G(enabled) = false;
JIT_G(on) = 0; JIT_G(on) = false;
} }
} }
#endif #endif
@@ -3251,13 +3251,13 @@ static zend_result accel_post_startup(void)
SHM_PROTECT(); SHM_PROTECT();
} else if (!ZCG(accel_directives).file_cache) { } else if (!ZCG(accel_directives).file_cache) {
accel_startup_ok = 0; accel_startup_ok = false;
zend_accel_error_noreturn(ACCEL_LOG_FATAL, "opcache.file_cache_only is set without a proper setting of opcache.file_cache"); zend_accel_error_noreturn(ACCEL_LOG_FATAL, "opcache.file_cache_only is set without a proper setting of opcache.file_cache");
return SUCCESS; return SUCCESS;
} else { } else {
#ifdef HAVE_JIT #ifdef HAVE_JIT
JIT_G(enabled) = 0; JIT_G(enabled) = false;
JIT_G(on) = 0; JIT_G(on) = false;
#endif #endif
accel_shared_globals = calloc(1, sizeof(zend_accel_shared_globals)); accel_shared_globals = calloc(1, sizeof(zend_accel_shared_globals));
} }
@@ -3295,7 +3295,7 @@ file_cache_fallback:
ini_entry->on_modify = accel_include_path_on_modify; ini_entry->on_modify = accel_include_path_on_modify;
} }
accel_startup_ok = 1; accel_startup_ok = true;
/* Override file_exists(), is_file() and is_readable() */ /* Override file_exists(), is_file() and is_readable() */
zend_accel_override_file_functions(); zend_accel_override_file_functions();
@@ -3338,7 +3338,7 @@ static void accel_post_shutdown(void)
void accel_shutdown(void) void accel_shutdown(void)
{ {
zend_ini_entry *ini_entry; zend_ini_entry *ini_entry;
bool _file_cache_only = 0; bool _file_cache_only = false;
#ifdef HAVE_JIT #ifdef HAVE_JIT
zend_jit_shutdown(); zend_jit_shutdown();
@@ -3397,10 +3397,10 @@ void zend_accel_schedule_restart(zend_accel_restart_reason reason)
HANDLE_BLOCK_INTERRUPTIONS(); HANDLE_BLOCK_INTERRUPTIONS();
SHM_UNPROTECT(); SHM_UNPROTECT();
ZCSG(restart_pending) = 1; ZCSG(restart_pending) = true;
ZCSG(restart_reason) = reason; ZCSG(restart_reason) = reason;
ZCSG(cache_status_before_restart) = ZCSG(accelerator_enabled); ZCSG(cache_status_before_restart) = ZCSG(accelerator_enabled);
ZCSG(accelerator_enabled) = 0; ZCSG(accelerator_enabled) = false;
if (ZCG(accel_directives).force_restart_timeout) { if (ZCG(accel_directives).force_restart_timeout) {
ZCSG(force_restart_time) = zend_accel_get_time() + ZCG(accel_directives).force_restart_timeout; ZCSG(force_restart_time) = zend_accel_get_time() + ZCG(accel_directives).force_restart_timeout;
@@ -3411,12 +3411,14 @@ void zend_accel_schedule_restart(zend_accel_restart_reason reason)
HANDLE_UNBLOCK_INTERRUPTIONS(); HANDLE_UNBLOCK_INTERRUPTIONS();
} }
/* this is needed because on WIN32 lock is not decreased unless ZCG(counted) is set */ static void accel_deactivate_now()
{
/* this is needed because on WIN32 lock is not decreased unless ZCG(counted) is set */
#ifdef ZEND_WIN32 #ifdef ZEND_WIN32
#define accel_deactivate_now() ZCG(counted) = 1; accel_deactivate_sub() ZCG(counted) = true;
#else
#define accel_deactivate_now() accel_deactivate_sub()
#endif #endif
accel_deactivate_sub();
}
/* ensures it is OK to read SHM /* ensures it is OK to read SHM
if it's not OK (restart in progress) returns FAILURE if it's not OK (restart in progress) returns FAILURE
@@ -3440,7 +3442,7 @@ int accelerator_shm_read_lock(void)
accel_deactivate_now(); /* drop usage lock */ accel_deactivate_now(); /* drop usage lock */
return FAILURE; return FAILURE;
} }
ZCG(counted) = 1; ZCG(counted) = true;
} }
return SUCCESS; return SUCCESS;
} }
@@ -3449,7 +3451,7 @@ int accelerator_shm_read_lock(void)
void accelerator_shm_read_unlock(void) void accelerator_shm_read_unlock(void)
{ {
if (!ZCG(counted)) { if (!ZCG(counted)) {
/* counted is 0 - meaning we had to readlock manually, release readlock now */ /* counted is false - meaning we had to readlock manually, release readlock now */
accel_deactivate_now(); accel_deactivate_now();
} }
} }
@@ -3528,7 +3530,7 @@ static void preload_move_user_functions(HashTable *src, HashTable *dst)
Bucket *p; Bucket *p;
dtor_func_t orig_dtor = src->pDestructor; dtor_func_t orig_dtor = src->pDestructor;
zend_string *filename = NULL; zend_string *filename = NULL;
int copy = 0; bool copy = false;
src->pDestructor = NULL; src->pDestructor = NULL;
zend_hash_extend(dst, dst->nNumUsed + src->nNumUsed, 0); zend_hash_extend(dst, dst->nNumUsed + src->nNumUsed, 0);
@@ -3546,7 +3548,7 @@ static void preload_move_user_functions(HashTable *src, HashTable *dst)
} }
} }
} else { } else {
copy = 0; copy = false;
} }
} }
if (copy) { if (copy) {
@@ -3567,7 +3569,7 @@ static void preload_move_user_classes(HashTable *src, HashTable *dst)
Bucket *p; Bucket *p;
dtor_func_t orig_dtor = src->pDestructor; dtor_func_t orig_dtor = src->pDestructor;
zend_string *filename = NULL; zend_string *filename = NULL;
int copy = 0; bool copy = false;
src->pDestructor = NULL; src->pDestructor = NULL;
zend_hash_extend(dst, dst->nNumUsed + src->nNumUsed, 0); zend_hash_extend(dst, dst->nNumUsed + src->nNumUsed, 0);
@@ -3584,7 +3586,7 @@ static void preload_move_user_classes(HashTable *src, HashTable *dst)
} }
} }
} else { } else {
copy = 0; copy = false;
} }
} }
if (copy) { if (copy) {
@@ -3728,21 +3730,21 @@ static zend_result preload_update_constant(zval *val, zend_class_entry *scope)
static bool preload_try_resolve_constants(zend_class_entry *ce) static bool preload_try_resolve_constants(zend_class_entry *ce)
{ {
bool ok, changed, was_changed = 0; bool ok, changed, was_changed = false;
zend_class_constant *c; zend_class_constant *c;
zval *val; zval *val;
EG(exception) = (void*)(uintptr_t)-1; /* prevent error reporting */ EG(exception) = (void*)(uintptr_t)-1; /* prevent error reporting */
do { do {
ok = 1; ok = true;
changed = 0; changed = false;
ZEND_HASH_MAP_FOREACH_PTR(&ce->constants_table, c) { ZEND_HASH_MAP_FOREACH_PTR(&ce->constants_table, c) {
val = &c->value; val = &c->value;
if (Z_TYPE_P(val) == IS_CONSTANT_AST) { if (Z_TYPE_P(val) == IS_CONSTANT_AST) {
if (EXPECTED(preload_update_constant(val, c->ce) == SUCCESS)) { if (EXPECTED(preload_update_constant(val, c->ce) == SUCCESS)) {
was_changed = changed = 1; was_changed = changed = true;
} else { } else {
ok = 0; ok = false;
} }
} }
} ZEND_HASH_FOREACH_END(); } ZEND_HASH_FOREACH_END();
@@ -3751,14 +3753,14 @@ static bool preload_try_resolve_constants(zend_class_entry *ce)
} }
if (ce->default_properties_count) { if (ce->default_properties_count) {
uint32_t i; uint32_t i;
bool resolved = 1; bool resolved = true;
for (i = 0; i < ce->default_properties_count; i++) { for (i = 0; i < ce->default_properties_count; i++) {
val = &ce->default_properties_table[i]; val = &ce->default_properties_table[i];
if (Z_TYPE_P(val) == IS_CONSTANT_AST) { if (Z_TYPE_P(val) == IS_CONSTANT_AST) {
zend_property_info *prop = ce->properties_info_table[i]; zend_property_info *prop = ce->properties_info_table[i];
if (UNEXPECTED(preload_update_constant(val, prop->ce) != SUCCESS)) { if (UNEXPECTED(preload_update_constant(val, prop->ce) != SUCCESS)) {
resolved = ok = 0; resolved = ok = false;
} }
} }
} }
@@ -3768,13 +3770,13 @@ static bool preload_try_resolve_constants(zend_class_entry *ce)
} }
if (ce->default_static_members_count) { if (ce->default_static_members_count) {
uint32_t count = ce->parent ? ce->default_static_members_count - ce->parent->default_static_members_count : ce->default_static_members_count; uint32_t count = ce->parent ? ce->default_static_members_count - ce->parent->default_static_members_count : ce->default_static_members_count;
bool resolved = 1; bool resolved = true;
val = ce->default_static_members_table + ce->default_static_members_count - 1; val = ce->default_static_members_table + ce->default_static_members_count - 1;
while (count) { while (count) {
if (Z_TYPE_P(val) == IS_CONSTANT_AST) { if (Z_TYPE_P(val) == IS_CONSTANT_AST) {
if (UNEXPECTED(preload_update_constant(val, ce) != SUCCESS)) { if (UNEXPECTED(preload_update_constant(val, ce) != SUCCESS)) {
resolved = ok = 0; resolved = ok = false;
} }
} }
val--; val--;
@@ -3786,7 +3788,7 @@ static bool preload_try_resolve_constants(zend_class_entry *ce)
} }
} while (changed && !ok); } while (changed && !ok);
EG(exception) = NULL; EG(exception) = NULL;
CG(in_compilation) = 0; CG(in_compilation) = false;
if (ok) { if (ok) {
ce->ce_flags |= ZEND_ACC_CONSTANTS_UPDATED; ce->ce_flags |= ZEND_ACC_CONSTANTS_UPDATED;
@@ -3875,7 +3877,7 @@ static void preload_link(void)
/* Resolve class dependencies */ /* Resolve class dependencies */
do { do {
changed = 0; changed = false;
ZEND_HASH_MAP_FOREACH_STR_KEY_VAL_FROM(EG(class_table), key, zv, EG(persistent_classes_count)) { ZEND_HASH_MAP_FOREACH_STR_KEY_VAL_FROM(EG(class_table), key, zv, EG(persistent_classes_count)) {
ce = Z_PTR_P(zv); ce = Z_PTR_P(zv);
@@ -3919,7 +3921,7 @@ static void preload_link(void)
zend_begin_record_errors(); zend_begin_record_errors();
/* Set filename & lineno information for inheritance errors */ /* Set filename & lineno information for inheritance errors */
CG(in_compilation) = 1; CG(in_compilation) = true;
CG(compiled_filename) = ce->info.user.filename; CG(compiled_filename) = ce->info.user.filename;
CG(zend_lineno) = ce->info.user.line_start; CG(zend_lineno) = ce->info.user.line_start;
zend_try { zend_try {
@@ -3958,7 +3960,7 @@ static void preload_link(void)
zend_hash_update_ptr(&errors, key, EG(errors)[EG(num_errors)-1]); zend_hash_update_ptr(&errors, key, EG(errors)[EG(num_errors)-1]);
EG(num_errors)--; EG(num_errors)--;
} zend_end_try(); } zend_end_try();
CG(in_compilation) = 0; CG(in_compilation) = false;
CG(compiled_filename) = NULL; CG(compiled_filename) = NULL;
zend_free_recorded_errors(); zend_free_recorded_errors();
zend_string_release(lcname); zend_string_release(lcname);
@@ -3966,7 +3968,7 @@ static void preload_link(void)
} while (changed); } while (changed);
do { do {
changed = 0; changed = false;
ZEND_HASH_MAP_REVERSE_FOREACH_VAL(EG(class_table), zv) { ZEND_HASH_MAP_REVERSE_FOREACH_VAL(EG(class_table), zv) {
ce = Z_PTR_P(zv); ce = Z_PTR_P(zv);
@@ -3975,11 +3977,11 @@ static void preload_link(void)
} }
if (!(ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) { if (!(ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) {
if (!(ce->ce_flags & ZEND_ACC_TRAIT)) { /* don't update traits */ if (!(ce->ce_flags & ZEND_ACC_TRAIT)) { /* don't update traits */
CG(in_compilation) = 1; /* prevent autoloading */ CG(in_compilation) = true; /* prevent autoloading */
if (preload_try_resolve_constants(ce)) { if (preload_try_resolve_constants(ce)) {
changed = 1; changed = true;
} }
CG(in_compilation) = 0; CG(in_compilation) = false;
} }
} }
} ZEND_HASH_FOREACH_END(); } ZEND_HASH_FOREACH_END();
@@ -4060,15 +4062,15 @@ static void preload_remove_empty_includes(void)
/* mark all as empty */ /* mark all as empty */
ZEND_HASH_MAP_FOREACH_PTR(preload_scripts, script) { ZEND_HASH_MAP_FOREACH_PTR(preload_scripts, script) {
script->empty = 1; script->empty = true;
} ZEND_HASH_FOREACH_END(); } ZEND_HASH_FOREACH_END();
/* find non empty scripts */ /* find non empty scripts */
do { do {
changed = 0; changed = false;
ZEND_HASH_MAP_FOREACH_PTR(preload_scripts, script) { ZEND_HASH_MAP_FOREACH_PTR(preload_scripts, script) {
if (script->empty) { if (script->empty) {
int empty = 1; bool empty = true;
zend_op *opline = script->script.main_op_array.opcodes; zend_op *opline = script->script.main_op_array.opcodes;
zend_op *end = opline + script->script.main_op_array.last; zend_op *end = opline + script->script.main_op_array.last;
@@ -4085,24 +4087,24 @@ static void preload_remove_empty_includes(void)
zend_persistent_script *incl = zend_hash_find_ptr(preload_scripts, resolved_path); zend_persistent_script *incl = zend_hash_find_ptr(preload_scripts, resolved_path);
zend_string_release(resolved_path); zend_string_release(resolved_path);
if (!incl || !incl->empty) { if (!incl || !incl->empty) {
empty = 0; empty = false;
break; break;
} }
} else { } else {
empty = 0; empty = false;
break; break;
} }
} else if (opline->opcode != ZEND_NOP && } else if (opline->opcode != ZEND_NOP &&
opline->opcode != ZEND_RETURN && opline->opcode != ZEND_RETURN &&
opline->opcode != ZEND_HANDLE_EXCEPTION) { opline->opcode != ZEND_HANDLE_EXCEPTION) {
empty = 0; empty = false;
break; break;
} }
opline++; opline++;
} }
if (!empty) { if (!empty) {
script->empty = 0; script->empty = false;
changed = 1; changed = true;
} }
} }
} ZEND_HASH_FOREACH_END(); } ZEND_HASH_FOREACH_END();
@@ -4326,8 +4328,8 @@ static int accel_preload(const char *config, bool in_child)
size_t orig_map_ptr_last; size_t orig_map_ptr_last;
uint32_t orig_compiler_options; uint32_t orig_compiler_options;
ZCG(enabled) = 0; ZCG(enabled) = false;
ZCG(accelerator_enabled) = 0; ZCG(accelerator_enabled) = false;
orig_open_basedir = PG(open_basedir); orig_open_basedir = PG(open_basedir);
PG(open_basedir) = NULL; PG(open_basedir) = NULL;
preload_orig_compile_file = accelerator_orig_compile_file; preload_orig_compile_file = accelerator_orig_compile_file;
@@ -4350,7 +4352,7 @@ static int accel_preload(const char *config, bool in_child)
CG(compiler_options) |= ZEND_COMPILE_DELAYED_BINDING; CG(compiler_options) |= ZEND_COMPILE_DELAYED_BINDING;
CG(compiler_options) |= ZEND_COMPILE_NO_CONSTANT_SUBSTITUTION; CG(compiler_options) |= ZEND_COMPILE_NO_CONSTANT_SUBSTITUTION;
CG(compiler_options) |= ZEND_COMPILE_IGNORE_OTHER_FILES; CG(compiler_options) |= ZEND_COMPILE_IGNORE_OTHER_FILES;
CG(skip_shebang) = 1; CG(skip_shebang) = true;
zend_try { zend_try {
zend_op_array *op_array; zend_op_array *op_array;
@@ -4371,7 +4373,7 @@ static int accel_preload(const char *config, bool in_child)
if (EG(exception)) { if (EG(exception)) {
ret = zend_exception_error(EG(exception), E_ERROR); ret = zend_exception_error(EG(exception), E_ERROR);
if (ret == FAILURE) { if (ret == FAILURE) {
CG(unclean_shutdown) = 1; CG(unclean_shutdown) = true;
} }
} }
} }
@@ -4382,7 +4384,7 @@ static int accel_preload(const char *config, bool in_child)
zend_exception_error(EG(exception), E_ERROR); zend_exception_error(EG(exception), E_ERROR);
} }
CG(unclean_shutdown) = 1; CG(unclean_shutdown) = true;
ret = FAILURE; ret = FAILURE;
} }
} zend_catch { } zend_catch {
@@ -4391,7 +4393,7 @@ static int accel_preload(const char *config, bool in_child)
PG(open_basedir) = orig_open_basedir; PG(open_basedir) = orig_open_basedir;
accelerator_orig_compile_file = preload_orig_compile_file; accelerator_orig_compile_file = preload_orig_compile_file;
ZCG(enabled) = 1; ZCG(enabled) = true;
zend_destroy_file_handle(&file_handle); zend_destroy_file_handle(&file_handle);
@@ -4575,7 +4577,7 @@ static int accel_finish_startup(void)
zend_accel_error_noreturn(ACCEL_LOG_ERROR, "Preloading is not supported on Windows"); zend_accel_error_noreturn(ACCEL_LOG_ERROR, "Preloading is not supported on Windows");
return FAILURE; return FAILURE;
#else #else
int in_child = 0; bool in_child = false;
int ret = SUCCESS; int ret = SUCCESS;
int rc; int rc;
int orig_error_reporting; int orig_error_reporting;
@@ -4644,7 +4646,7 @@ static int accel_finish_startup(void)
zend_accel_error(ACCEL_LOG_WARNING, "Preloading failed to setuid(%d)", pw->pw_uid); zend_accel_error(ACCEL_LOG_WARNING, "Preloading failed to setuid(%d)", pw->pw_uid);
exit(1); exit(1);
} }
in_child = 1; in_child = true;
} else { /* parent */ } else { /* parent */
int status; int status;
@@ -4685,7 +4687,7 @@ static int accel_finish_startup(void)
zend_interned_strings_switch_storage(1); zend_interned_strings_switch_storage(1);
#ifdef ZEND_SIGNALS #ifdef ZEND_SIGNALS
SIGG(reset) = 0; SIGG(reset) = false;
#endif #endif
orig_error_reporting = EG(error_reporting); orig_error_reporting = EG(error_reporting);
@@ -4699,8 +4701,8 @@ static int accel_finish_startup(void)
bool orig_report_memleaks; bool orig_report_memleaks;
/* don't send headers */ /* don't send headers */
SG(headers_sent) = 1; SG(headers_sent) = true;
SG(request_info).no_headers = 1; SG(request_info).no_headers = true;
php_output_set_status(0); php_output_set_status(0);
ZCG(auto_globals_mask) = 0; ZCG(auto_globals_mask) = 0;
@@ -4708,11 +4710,11 @@ static int accel_finish_startup(void)
ZCG(cache_opline) = NULL; ZCG(cache_opline) = NULL;
ZCG(cache_persistent_script) = NULL; ZCG(cache_persistent_script) = NULL;
ZCG(include_path_key_len) = 0; ZCG(include_path_key_len) = 0;
ZCG(include_path_check) = 1; ZCG(include_path_check) = true;
ZCG(cwd) = NULL; ZCG(cwd) = NULL;
ZCG(cwd_key_len) = 0; ZCG(cwd_key_len) = 0;
ZCG(cwd_check) = 1; ZCG(cwd_check) = true;
if (accel_preload(ZCG(accel_directives).preload, in_child) != SUCCESS) { if (accel_preload(ZCG(accel_directives).preload, in_child) != SUCCESS) {
ret = FAILURE; ret = FAILURE;
@@ -4720,11 +4722,11 @@ static int accel_finish_startup(void)
preload_flush(NULL); preload_flush(NULL);
orig_report_memleaks = PG(report_memleaks); orig_report_memleaks = PG(report_memleaks);
PG(report_memleaks) = 0; PG(report_memleaks) = false;
#ifdef ZEND_SIGNALS #ifdef ZEND_SIGNALS
/* We may not have registered signal handlers due to SIGG(reset)=0, so /* We may not have registered signal handlers due to SIGG(reset)=0, so
* also disable the check that they are registered. */ * also disable the check that they are registered. */
SIGG(check) = 0; SIGG(check) = false;
#endif #endif
php_request_shutdown(NULL); /* calls zend_shared_alloc_unlock(); */ php_request_shutdown(NULL); /* calls zend_shared_alloc_unlock(); */
PG(report_memleaks) = orig_report_memleaks; PG(report_memleaks) = orig_report_memleaks;
+3 -3
View File
@@ -204,7 +204,7 @@ typedef struct _zend_accel_directives {
} zend_accel_directives; } zend_accel_directives;
typedef struct _zend_accel_globals { typedef struct _zend_accel_globals {
int counted; /* the process uses shared memory */ bool counted; /* the process uses shared memory */
bool enabled; bool enabled;
bool locked; /* thread obtained exclusive lock */ bool locked; /* thread obtained exclusive lock */
bool accelerator_enabled; /* accelerator enabled for current request */ bool accelerator_enabled; /* accelerator enabled for current request */
@@ -215,9 +215,9 @@ typedef struct _zend_accel_globals {
char include_path_key[32]; /* key of current "include_path" */ char include_path_key[32]; /* key of current "include_path" */
char cwd_key[32]; /* key of current working directory */ char cwd_key[32]; /* key of current working directory */
int include_path_key_len; int include_path_key_len;
int include_path_check; bool include_path_check;
int cwd_key_len; int cwd_key_len;
int cwd_check; bool cwd_check;
int auto_globals_mask; int auto_globals_mask;
time_t request_time; time_t request_time;
time_t last_restart_time; /* used to synchronize SHM and in-process caches */ time_t last_restart_time; /* used to synchronize SHM and in-process caches */
+46 -44
View File
@@ -253,15 +253,18 @@ static void *zend_file_cache_serialize_interned(zend_string *str,
len = ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(ZSTR_LEN(str))); len = ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(ZSTR_LEN(str)));
ret = (void*)(info->str_size | Z_UL(1)); ret = (void*)(info->str_size | Z_UL(1));
zend_shared_alloc_register_xlat_entry(str, ret); zend_shared_alloc_register_xlat_entry(str, ret);
if (info->str_size + len > ZSTR_LEN((zend_string*)ZCG(mem))) {
zend_string *s = (zend_string*)ZCG(mem);
if (info->str_size + len > ZSTR_LEN(s)) {
size_t new_len = info->str_size + len; size_t new_len = info->str_size + len;
ZCG(mem) = (void*)zend_string_realloc( s = zend_string_realloc(
(zend_string*)ZCG(mem), s,
((_ZSTR_HEADER_SIZE + 1 + new_len + 4095) & ~0xfff) - (_ZSTR_HEADER_SIZE + 1), ((_ZSTR_HEADER_SIZE + 1 + new_len + 4095) & ~0xfff) - (_ZSTR_HEADER_SIZE + 1),
0); 0);
ZCG(mem) = (void*)s;
} }
zend_string *new_str = (zend_string *) (ZSTR_VAL((zend_string*)ZCG(mem)) + info->str_size); zend_string *new_str = (zend_string *) (ZSTR_VAL(s) + info->str_size);
memcpy(new_str, str, len); memcpy(new_str, str, len);
GC_ADD_FLAGS(new_str, IS_STR_INTERNED); GC_ADD_FLAGS(new_str, IS_STR_INTERNED);
GC_DEL_FLAGS(new_str, IS_STR_PERMANENT|IS_STR_CLASS_NAME_MAP_PTR); GC_DEL_FLAGS(new_str, IS_STR_PERMANENT|IS_STR_CLASS_NAME_MAP_PTR);
@@ -269,7 +272,7 @@ static void *zend_file_cache_serialize_interned(zend_string *str,
return ret; return ret;
} }
static void *zend_file_cache_unserialize_interned(zend_string *str, int in_shm) static void *zend_file_cache_unserialize_interned(zend_string *str, bool in_shm)
{ {
str = (zend_string*)((char*)ZCG(mem) + ((size_t)(str) & ~Z_UL(1))); str = (zend_string*)((char*)ZCG(mem) + ((size_t)(str) & ~Z_UL(1)));
if (!in_shm) { if (!in_shm) {
@@ -1006,14 +1009,34 @@ static char *zend_file_cache_get_bin_file_path(zend_string *script_path)
return filename; return filename;
} }
int zend_file_cache_script_store(zend_persistent_script *script, int in_shm) /**
* Helper function for zend_file_cache_script_store().
*
* @return true on success, false on error
*/
static bool zend_file_cache_script_write(int fd, const zend_persistent_script *script, const zend_file_cache_metainfo *info, const void *buf, const zend_string *s)
{
#ifdef HAVE_SYS_UIO_H
const struct iovec vec[] = {
{ .iov_base = (void *)info, .iov_len = sizeof(*info) },
{ .iov_base = (void *)buf, .iov_len = script->size },
{ .iov_base = (void *)ZSTR_VAL(s), .iov_len = info->str_size },
};
return writev(fd, vec, sizeof(vec) / sizeof(vec[0])) == (ssize_t)(sizeof(*info) + script->size + info->str_size);
#else
return ZEND_LONG_MAX >= (zend_long)(sizeof(*info) + script->size + info->str_size) &&
write(fd, info, sizeof(*info)) == sizeof(*info) &&
write(fd, buf, script->size) == script->size &&
write(fd, ZSTR_VAL(s), info->str_size) == info->str_size;
#endif
}
int zend_file_cache_script_store(zend_persistent_script *script, bool in_shm)
{ {
int fd; int fd;
char *filename; char *filename;
zend_file_cache_metainfo info; zend_file_cache_metainfo info;
#ifdef HAVE_SYS_UIO_H
struct iovec vec[3];
#endif
void *mem, *buf; void *mem, *buf;
#ifdef HAVE_JIT #ifdef HAVE_JIT
@@ -1058,16 +1081,18 @@ int zend_file_cache_script_store(zend_persistent_script *script, int in_shm)
zend_shared_alloc_init_xlat_table(); zend_shared_alloc_init_xlat_table();
if (!in_shm) { if (!in_shm) {
script->corrupted = 1; /* used to check if script restored to SHM or process memory */ script->corrupted = true; /* used to check if script restored to SHM or process memory */
} }
zend_file_cache_serialize(script, &info, buf); zend_file_cache_serialize(script, &info, buf);
if (!in_shm) { if (!in_shm) {
script->corrupted = 0; script->corrupted = false;
} }
zend_shared_alloc_destroy_xlat_table(); zend_shared_alloc_destroy_xlat_table();
zend_string *const s = (zend_string*)ZCG(mem);
info.checksum = zend_adler32(ADLER32_INIT, buf, script->size); info.checksum = zend_adler32(ADLER32_INIT, buf, script->size);
info.checksum = zend_adler32(info.checksum, (unsigned char*)ZSTR_VAL((zend_string*)ZCG(mem)), info.str_size); info.checksum = zend_adler32(info.checksum, (unsigned char*)ZSTR_VAL(s), info.str_size);
#if __has_feature(memory_sanitizer) #if __has_feature(memory_sanitizer)
/* The buffer may contain uninitialized regions. However, the uninitialized parts will not be /* The buffer may contain uninitialized regions. However, the uninitialized parts will not be
@@ -1077,40 +1102,17 @@ int zend_file_cache_script_store(zend_persistent_script *script, int in_shm)
__msan_unpoison(buf, script->size); __msan_unpoison(buf, script->size);
#endif #endif
#ifdef HAVE_SYS_UIO_H if (!zend_file_cache_script_write(fd, script, &info, buf, s)) {
vec[0].iov_base = (void *)&info;
vec[0].iov_len = sizeof(info);
vec[1].iov_base = buf;
vec[1].iov_len = script->size;
vec[2].iov_base = ZSTR_VAL((zend_string*)ZCG(mem));
vec[2].iov_len = info.str_size;
if (writev(fd, vec, 3) != (ssize_t)(sizeof(info) + script->size + info.str_size)) {
zend_accel_error(ACCEL_LOG_WARNING, "opcache cannot write to file '%s'\n", filename); zend_accel_error(ACCEL_LOG_WARNING, "opcache cannot write to file '%s'\n", filename);
zend_string_release_ex((zend_string*)ZCG(mem), 0); zend_string_release_ex(s, 0);
close(fd); close(fd);
efree(mem); efree(mem);
zend_file_cache_unlink(filename); zend_file_cache_unlink(filename);
efree(filename); efree(filename);
return FAILURE; return FAILURE;
} }
#else
if (ZEND_LONG_MAX < (zend_long)(sizeof(info) + script->size + info.str_size) ||
write(fd, &info, sizeof(info)) != sizeof(info) ||
write(fd, buf, script->size) != script->size ||
write(fd, ((zend_string*)ZCG(mem))->val, info.str_size) != info.str_size
) {
zend_accel_error(ACCEL_LOG_WARNING, "opcache cannot write to file '%s'\n", filename);
zend_string_release_ex((zend_string*)ZCG(mem), 0);
close(fd);
efree(mem);
zend_file_cache_unlink(filename);
efree(filename);
return FAILURE;
}
#endif
zend_string_release_ex((zend_string*)ZCG(mem), 0); zend_string_release_ex(s, 0);
efree(mem); efree(mem);
if (zend_file_cache_flock(fd, LOCK_UN) != 0) { if (zend_file_cache_flock(fd, LOCK_UN) != 0) {
zend_accel_error(ACCEL_LOG_WARNING, "opcache cannot unlock file '%s'\n", filename); zend_accel_error(ACCEL_LOG_WARNING, "opcache cannot unlock file '%s'\n", filename);
@@ -1744,9 +1746,9 @@ zend_persistent_script *zend_file_cache_script_load(zend_file_handle *file_handl
zend_file_cache_metainfo info; zend_file_cache_metainfo info;
zend_accel_hash_entry *bucket; zend_accel_hash_entry *bucket;
void *mem, *checkpoint, *buf; void *mem, *checkpoint, *buf;
int cache_it = 1; bool cache_it = true;
unsigned int actual_checksum; unsigned int actual_checksum;
int ok; bool ok;
if (!full_path) { if (!full_path) {
return NULL; return NULL;
@@ -1878,18 +1880,18 @@ zend_persistent_script *zend_file_cache_script_load(zend_file_handle *file_handl
} else { } else {
use_process_mem: use_process_mem:
buf = mem; buf = mem;
cache_it = 0; cache_it = false;
} }
ZCG(mem) = ((char*)mem + info.mem_size); ZCG(mem) = ((char*)mem + info.mem_size);
script = (zend_persistent_script*)((char*)buf + info.script_offset); script = (zend_persistent_script*)((char*)buf + info.script_offset);
script->corrupted = !cache_it; /* used to check if script restored to SHM or process memory */ script->corrupted = !cache_it; /* used to check if script restored to SHM or process memory */
ok = 1; ok = true;
zend_try { zend_try {
zend_file_cache_unserialize(script, buf); zend_file_cache_unserialize(script, buf);
} zend_catch { } zend_catch {
ok = 0; ok = false;
} zend_end_try(); } zend_end_try();
if (!ok) { if (!ok) {
if (cache_it) { if (cache_it) {
@@ -1902,7 +1904,7 @@ use_process_mem:
} }
} }
script->corrupted = 0; script->corrupted = false;
if (cache_it) { if (cache_it) {
ZCSG(map_ptr_last) = CG(map_ptr_last); ZCSG(map_ptr_last) = CG(map_ptr_last);
+1 -1
View File
@@ -19,7 +19,7 @@
#ifndef ZEND_FILE_CACHE_H #ifndef ZEND_FILE_CACHE_H
#define ZEND_FILE_CACHE_H #define ZEND_FILE_CACHE_H
int zend_file_cache_script_store(zend_persistent_script *script, int in_shm); int zend_file_cache_script_store(zend_persistent_script *script, bool in_shm);
zend_persistent_script *zend_file_cache_script_load(zend_file_handle *file_handle); zend_persistent_script *zend_file_cache_script_load(zend_file_handle *file_handle);
void zend_file_cache_invalidate(zend_string *full_path); void zend_file_cache_invalidate(zend_string *full_path);
+3 -3
View File
@@ -1331,12 +1331,12 @@ zend_persistent_script *zend_accel_script_persist(zend_persistent_script *script
ZEND_ASSERT(((zend_uintptr_t)ZCG(mem) & 0x7) == 0); /* should be 8 byte aligned */ ZEND_ASSERT(((zend_uintptr_t)ZCG(mem) & 0x7) == 0); /* should be 8 byte aligned */
script = zend_shared_memdup_free(script, sizeof(zend_persistent_script)); script = zend_shared_memdup_free(script, sizeof(zend_persistent_script));
script->corrupted = 0; script->corrupted = false;
ZCG(current_persistent_script) = script; ZCG(current_persistent_script) = script;
if (!for_shm) { if (!for_shm) {
/* script is not going to be saved in SHM */ /* script is not going to be saved in SHM */
script->corrupted = 1; script->corrupted = true;
} }
zend_accel_store_interned_string(script->script.filename); zend_accel_store_interned_string(script->script.filename);
@@ -1392,7 +1392,7 @@ zend_persistent_script *zend_accel_script_persist(zend_persistent_script *script
} }
#endif #endif
script->corrupted = 0; script->corrupted = false;
ZCG(current_persistent_script) = NULL; ZCG(current_persistent_script) = NULL;
return script; return script;
+3 -3
View File
@@ -610,12 +610,12 @@ uint32_t zend_accel_script_persist_calc(zend_persistent_script *new_persistent_s
new_persistent_script->mem = NULL; new_persistent_script->mem = NULL;
new_persistent_script->size = 0; new_persistent_script->size = 0;
new_persistent_script->corrupted = 0; new_persistent_script->corrupted = false;
ZCG(current_persistent_script) = new_persistent_script; ZCG(current_persistent_script) = new_persistent_script;
if (!for_shm) { if (!for_shm) {
/* script is not going to be saved in SHM */ /* script is not going to be saved in SHM */
new_persistent_script->corrupted = 1; new_persistent_script->corrupted = true;
} }
ADD_SIZE(sizeof(zend_persistent_script)); ADD_SIZE(sizeof(zend_persistent_script));
@@ -645,7 +645,7 @@ uint32_t zend_accel_script_persist_calc(zend_persistent_script *new_persistent_s
zend_persist_early_bindings_calc( zend_persist_early_bindings_calc(
new_persistent_script->num_early_bindings, new_persistent_script->early_bindings); new_persistent_script->num_early_bindings, new_persistent_script->early_bindings);
new_persistent_script->corrupted = 0; new_persistent_script->corrupted = false;
ZCG(current_persistent_script) = NULL; ZCG(current_persistent_script) = NULL;