summaryrefslogtreecommitdiff
path: root/ext/opcache
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2015-05-20 23:33:55 +0300
committerDmitry Stogov <dmitry@zend.com>2015-05-20 23:33:55 +0300
commitcf6ac5c66527afcd8cceafff86b485d2ddba6d1b (patch)
treeb78da10d6495900d24aa40a83cf8c036bc152693 /ext/opcache
parent5ff5201543971bb793b634d7dab5f0dc7f802a60 (diff)
downloadphp-git-cf6ac5c66527afcd8cceafff86b485d2ddba6d1b.tar.gz
Fixed SHM+FILE cache with opcache.protect_memory=1
Diffstat (limited to 'ext/opcache')
-rw-r--r--ext/opcache/zend_file_cache.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/ext/opcache/zend_file_cache.c b/ext/opcache/zend_file_cache.c
index 52ee49d5e1..219bb50820 100644
--- a/ext/opcache/zend_file_cache.c
+++ b/ext/opcache/zend_file_cache.c
@@ -113,8 +113,6 @@ static int zend_file_cache_flock(int fd, int type)
ZEND_ASSERT(IS_UNSERIALIZED(ptr)); \
/* script->corrupted shows if the script in SHM or not */ \
if (EXPECTED(script->corrupted)) { \
- GC_FLAGS(ptr) |= IS_STR_INTERNED | IS_STR_PERMANENT; \
- } else { \
GC_FLAGS(ptr) |= IS_STR_INTERNED; \
GC_FLAGS(ptr) &= ~IS_STR_PERMANENT; \
} \
@@ -125,12 +123,12 @@ static int zend_file_cache_flock(int fd, int type)
#define UNSERIALIZE_STR(ptr) do { \
if (ptr) { \
if (IS_SERIALIZED_INTERNED(ptr)) { \
- (ptr) = (void*)zend_file_cache_unserialize_interned((zend_string*)(ptr), script->corrupted); \
+ (ptr) = (void*)zend_file_cache_unserialize_interned((zend_string*)(ptr), !script->corrupted); \
} else { \
ZEND_ASSERT(IS_SERIALIZED(ptr)); \
(ptr) = (void*)((char*)buf + (size_t)(ptr)); \
/* script->corrupted shows if the script in SHM or not */ \
- if (EXPECTED(script->corrupted)) { \
+ if (EXPECTED(!script->corrupted)) { \
GC_FLAGS(ptr) |= IS_STR_INTERNED | IS_STR_PERMANENT; \
} else { \
GC_FLAGS(ptr) |= IS_STR_INTERNED; \
@@ -722,9 +720,13 @@ int zend_file_cache_script_store(zend_persistent_script *script, int in_shm)
ZCG(mem) = zend_string_alloc(4096 - (_STR_HEADER_SIZE + 1), 0);
zend_shared_alloc_init_xlat_table();
- script->corrupted = in_shm; /* used to check if script restored to SHM or process memory */
+ if (!in_shm) {
+ script->corrupted = 1; /* used to check if script restored to SHM or process memory */
+ }
zend_file_cache_serialize(script, &info, buf);
- script->corrupted = 0;
+ if (!in_shm) {
+ script->corrupted = 0;
+ }
zend_shared_alloc_destroy_xlat_table();
info.checksum = zend_adler32(ADLER32_INIT, buf, script->size);
@@ -1307,7 +1309,7 @@ use_process_mem:
ZCG(mem) = ((char*)mem + info.mem_size);
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 */
zend_file_cache_unserialize(script, buf);
script->corrupted = 0;