com php-src: Reuse interned strings from opcache SHM, if possible.: ext/mysqlnd/mysqlnd_wireprotocol.c ext/opcache/ZendAccele rator.c
| From: | Dmitry Stogov | Date: | Mon, 16 Oct 2017 16:20:16 +0000 |
| Subject: | com php-src: Reuse interned strings from opcache SHM, if possible.: ext/mysqlnd/mysqlnd_wireprotocol.c ext/opcache/ZendAccele rator.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-99767@lists.php.net to get a copy of this message | ||
Commit: 1dd224dd12d16984879337bb15431a2e1d3288b5
Author: Dmitry Stogov <dmitry@zend.com> Mon, 16 Oct 2017 19:20:16 +0300
Parents: a87484aa22334b668270d0fe271a407472c1cc42
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=1dd224dd12d16984879337bb15431a2e1d3288b5
Log:
Reuse interned strings from opcache SHM, if possible.
Changed paths:
M ext/mysqlnd/mysqlnd_wireprotocol.c
M ext/opcache/ZendAccelerator.c
Diff:
diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.c b/ext/mysqlnd/mysqlnd_wireprotocol.c
index 9d95174..b948b8b 100644
--- a/ext/mysqlnd/mysqlnd_wireprotocol.c
+++ b/ext/mysqlnd/mysqlnd_wireprotocol.c
@@ -1375,7 +1375,7 @@ php_mysqlnd_rset_field_read(void * _packet)
meta->root_len = total_len;
if (meta->name != mysqlnd_empty_string) {
- meta->sname = zend_string_init(meta->name, meta->name_length,
packet->persistent_alloc);
+ meta->sname = zend_new_interned_string(zend_string_init(meta->name, meta->name_length,
packet->persistent_alloc));
} else {
meta->sname = ZSTR_EMPTY_ALLOC();
}
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c
index 78dc603..501aae4 100644
--- a/ext/opcache/ZendAccelerator.c
+++ b/ext/opcache/ZendAccelerator.c
@@ -346,10 +346,6 @@ static inline void accel_unlock_all(void)
* it creates interned strings in shared memory when saves a script.
* Such interned strings are shared across all PHP processes
*/
-static zend_string *accel_new_interned_string_for_php(zend_string *str)
-{
- return str;
-}
static void accel_interned_strings_restore_state(void)
{
@@ -491,6 +487,19 @@ zend_string *accel_new_interned_string(zend_string *str)
return p->key;
}
+static zend_string *accel_new_interned_string_for_php(zend_string *str)
+{
+ if (ZCG(counted)) {
+ zend_string *ret = accel_find_interned_string(str);
+
+ if (ret) {
+ zend_string_release(str);
+ return ret;
+ }
+ }
+ return str;
+}
+
/* Copy PHP interned strings from PHP process memory into the shared memory */
static void accel_copy_permanent_strings(zend_new_interned_string_func_t new_interned_string)
{