]> granicus.if.org Git - php/commitdiff
Backport 7ff13badda58b966ff8fbcc61add48bb5b14117b into 7.0+
authorAnatol Belski <ab@php.net>
Wed, 18 Oct 2017 14:02:56 +0000 (16:02 +0200)
committerAnatol Belski <ab@php.net>
Wed, 18 Oct 2017 14:02:56 +0000 (16:02 +0200)
ext/opcache/ZendAccelerator.c
ext/opcache/zend_persist.h
ext/opcache/zend_persist_calc.c

index 4c57e5c91e3157dbb2f6de6f4f263265ef6dc6ec..52276010afdc6123404e4906ec1ab04a8f48616f 100644 (file)
@@ -1221,7 +1221,7 @@ static zend_persistent_script *cache_script_in_file_cache(zend_persistent_script
        zend_shared_alloc_init_xlat_table();
 
        /* Calculate the required memory size */
-       memory_used = zend_accel_script_persist_calc(new_persistent_script, NULL, 0);
+       memory_used = zend_accel_script_persist_calc(new_persistent_script, NULL, 0, 0);
 
        /* Allocate memory block */
 #ifdef __SSE2__
@@ -1309,7 +1309,7 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr
        zend_shared_alloc_init_xlat_table();
 
        /* Calculate the required memory size */
-       memory_used = zend_accel_script_persist_calc(new_persistent_script, key, key_length);
+       memory_used = zend_accel_script_persist_calc(new_persistent_script, key, key_length, 1);
 
        /* Allocate shared memory */
 #ifdef __SSE2__
index cb98cee1874fe9de19faf1ffcf908d1977247d45..fc35eac5c88dcf25d1699ca928928f196177f6a3 100644 (file)
@@ -23,7 +23,7 @@
 #define ZEND_PERSIST_H
 
 int zend_accel_script_persistable(zend_persistent_script *script);
-uint zend_accel_script_persist_calc(zend_persistent_script *script, char *key, unsigned int key_length);
+uint zend_accel_script_persist_calc(zend_persistent_script *script, char *key, unsigned int key_length, int for_shm);
 zend_persistent_script *zend_accel_script_persist(zend_persistent_script *script, char **key, unsigned int key_length);
 
 #endif /* ZEND_PERSIST_H */
index 369c57cf8482f8c97e616ad128c3936dd5b0b702..fda2aeba2a35f3f608e786f960e82aa05c805135 100644 (file)
@@ -381,7 +381,7 @@ static void zend_accel_persist_class_table_calc(HashTable *class_table)
        zend_hash_persist_calc(class_table, zend_persist_class_entry_calc);
 }
 
-uint zend_accel_script_persist_calc(zend_persistent_script *new_persistent_script, char *key, unsigned int key_length)
+uint zend_accel_script_persist_calc(zend_persistent_script *new_persistent_script, char *key, unsigned int key_length, int for_shm)
 {
        new_persistent_script->mem = NULL;
        new_persistent_script->size = 0;
@@ -390,12 +390,14 @@ uint zend_accel_script_persist_calc(zend_persistent_script *new_persistent_scrip
        new_persistent_script->corrupted = 0;
        ZCG(current_persistent_script) = new_persistent_script;
 
+       if (!for_shm) {
+               /* script is not going to be saved in SHM */
+               new_persistent_script->corrupted = 1;
+       }
+
        ADD_DUP_SIZE(new_persistent_script, sizeof(zend_persistent_script));
        if (key) {
                ADD_DUP_SIZE(key, key_length + 1);
-       } else {
-               /* script is not going to be saved in SHM */
-               new_persistent_script->corrupted = 1;
        }
        ADD_STRING(new_persistent_script->full_path);