]> granicus.if.org Git - php/commitdiff
Fixed required SHM memeory size calculation for scripts when opcache.revalidate_path...
authorDmitry Stogov <dmitry@zend.com>
Wed, 18 Oct 2017 11:26:44 +0000 (14:26 +0300)
committerDmitry Stogov <dmitry@zend.com>
Wed, 18 Oct 2017 11:26:44 +0000 (14:26 +0300)
ext/opcache/ZendAccelerator.c
ext/opcache/zend_persist.h
ext/opcache/zend_persist_calc.c

index 501aae48b137061e9383802af733a4e8f26b2163..e24262fb205fd4bc52829d075304042d5f34ef42 100644 (file)
@@ -1276,7 +1276,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__
@@ -1364,7 +1364,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 a87774a116879bb283428e343d35a228433d71e2..f1a036b880d887712a710451917d5e7c33acd5d1 100644 (file)
@@ -23,7 +23,7 @@
 #define ZEND_PERSIST_H
 
 int zend_accel_script_persistable(zend_persistent_script *script);
-uint32_t zend_accel_script_persist_calc(zend_persistent_script *script, char *key, unsigned int key_length);
+uint32_t 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 0c600daef558525285eaac3106bd463c776132e3..312d0d164d2d1e59a6902dd5809dce7910ff2ad6 100644 (file)
@@ -394,7 +394,7 @@ static void zend_accel_persist_class_table_calc(HashTable *class_table)
        zend_hash_persist_calc(class_table, zend_persist_class_entry_calc);
 }
 
-uint32_t zend_accel_script_persist_calc(zend_persistent_script *new_persistent_script, char *key, unsigned int key_length)
+uint32_t 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;
@@ -403,12 +403,14 @@ uint32_t zend_accel_script_persist_calc(zend_persistent_script *new_persistent_s
        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->script.filename);