From: Dmitry Stogov Date: Wed, 9 Apr 2014 05:43:42 +0000 (+0400) Subject: Fixed store of "shared" zend_strings X-Git-Tag: POST_PHPNG_MERGE~412^2~153 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=479f520d14ed221765af3ff5a3eb77dc54e1defa;p=php Fixed store of "shared" zend_strings --- diff --git a/ext/opcache/zend_persist.c b/ext/opcache/zend_persist.c index 20f57525cd..776359e6be 100644 --- a/ext/opcache/zend_persist.c +++ b/ext/opcache/zend_persist.c @@ -34,12 +34,23 @@ _zend_shared_memdup((void*)p, size, 0 TSRMLS_CC) #if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO -# define zend_accel_store_string(str) \ - zend_accel_store(str, sizeof(zend_string) + (str)->len) +# define zend_accel_store_string(str) do { \ + zend_string *new_str = zend_shared_alloc_get_xlat_entry(str); \ + if (new_str) { \ + str = new_str; \ + } else { \ + new_str = _zend_shared_memdup((void*)str, sizeof(zend_string) + (str)->len, 0 TSRMLS_CC); \ + efree(str); \ + str = new_str; \ + } \ + } while (0) # define zend_accel_memdup_string(str) \ zend_accel_memdup(str, sizeof(zend_string) + (str)->len) -# define zend_accel_store_interned_string(str) \ - (IS_ACCEL_INTERNED(str) ? str : zend_accel_store_string(str)) +# define zend_accel_store_interned_string(str) do { \ + if (!IS_ACCEL_INTERNED(str)) { \ + zend_accel_store_string(str); \ + } \ + } while (0) # define zend_accel_memdup_interned_string(str) \ (IS_ACCEL_INTERNED(str) ? str : zend_accel_memdup_string(str)) #else diff --git a/ext/opcache/zend_shared_alloc.c b/ext/opcache/zend_shared_alloc.c index 73f331de6f..4a31d3de6a 100644 --- a/ext/opcache/zend_shared_alloc.c +++ b/ext/opcache/zend_shared_alloc.c @@ -348,7 +348,6 @@ void *_zend_shared_memdup(void *source, size_t size, zend_bool free_source TSRML memcpy(retval, source, size); if (free_source) { efree(source); -//??? interned_efree((char*)source); } zend_shared_alloc_register_xlat_entry(source, retval); return retval;