Skip to content

Commit 9524849

Browse files
committed
Prefer already cached version of the script
1 parent 3b62e8b commit 9524849

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

ext/opcache/ZendAccelerator.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,7 +1471,14 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr
14711471
zend_accel_add_key(key, key_length, bucket);
14721472
}
14731473
zend_shared_alloc_unlock();
1474+
#if 1
1475+
/* prefer the script already stored in SHM */
1476+
free_persistent_script(new_persistent_script, 1);
1477+
*from_shared_memory = 1;
1478+
return existing_persistent_script;
1479+
#else
14741480
return new_persistent_script;
1481+
#endif
14751482
}
14761483
}
14771484

ext/opcache/zend_accelerator_util_funcs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ void free_persistent_script(zend_persistent_script *persistent_script, int destr
6464
if (!destroy_elements) {
6565
persistent_script->script.function_table.pDestructor = NULL;
6666
persistent_script->script.class_table.pDestructor = NULL;
67+
} else {
68+
destroy_op_array(&persistent_script->script.main_op_array);
6769
}
6870

6971
zend_hash_destroy(&persistent_script->script.function_table);

0 commit comments

Comments
 (0)