com php-src: Fixed required SHM memeory size calculation for scripts when opcache.revalidate_path is set.: ext/opcache/Zend Accelerator.c
ext/opcache/zend_persist.h ext/opcache/ zend_persist_calc.c
| From: | Dmitry Stogov | Date: | Wed, 18 Oct 2017 11:26:44 +0000 |
| Subject: | com php-src: Fixed required SHM memeory size calculation for scripts when opcache.revalidate_path is set.: ext/opcache/Zend Accelerator.c ext/opcache/zend_persist.h ext/opcache/ zend_persist_calc.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-99783@lists.php.net to get a copy of this message | ||
Commit: 7ff13badda58b966ff8fbcc61add48bb5b14117b
Author: Dmitry Stogov <dmitry@zend.com> Wed, 18 Oct 2017 14:26:44 +0300
Parents: d042d1d8e094fbf7fc4f595542874f37dabd2b83
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7ff13badda58b966ff8fbcc61add48bb5b14117b
Log:
Fixed required SHM memeory size calculation for scripts when opcache.revalidate_path is set.
Changed paths:
M ext/opcache/ZendAccelerator.c
M ext/opcache/zend_persist.h
M ext/opcache/zend_persist_calc.c
Diff:
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c
index 501aae4..e24262f 100644
--- a/ext/opcache/ZendAccelerator.c
+++ b/ext/opcache/ZendAccelerator.c
@@ -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__
diff --git a/ext/opcache/zend_persist.h b/ext/opcache/zend_persist.h
index a87774a..f1a036b 100644
--- a/ext/opcache/zend_persist.h
+++ b/ext/opcache/zend_persist.h
@@ -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 */
diff --git a/ext/opcache/zend_persist_calc.c b/ext/opcache/zend_persist_calc.c
index 0c600da..312d0d1 100644
--- a/ext/opcache/zend_persist_calc.c
+++ b/ext/opcache/zend_persist_calc.c
@@ -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);