php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | |
Patch Opcache-isb.patch for opcache Bug #66461Patch version 2014-01-10 18:46 UTC Return to Bug #66461 | Download this patchThis patch is obsolete Obsoleted by patches: Patch Revisions:Developer: Terry@ellisons.org.uk--- a/zend_accelerator_module.c +++ b/zend_accelerator_module.c @@ -134,6 +134,44 @@ static ZEND_INI_MH(OnUpdateMemoryConsumption) return SUCCESS; } +static ZEND_INI_MH(OnUpdateInternedStringsBuffer) +{ + long *p; + long buffer_size; +#ifndef ZTS + char *base = (char *) mh_arg2; +#else + char *base = (char *) ts_resource(*((int *) mh_arg2)); +#endif + + /* keep the compiler happy */ + (void)entry; (void)new_value_length; (void)mh_arg2; (void)mh_arg3; (void)stage; + + p = (long *) (base + (size_t)mh_arg1); + buffer_size = atoi(new_value); + /* sanity check we must use at least 2 MB */ + if (buffer_size < 1) { + const char *new_new_value = "1"; + zend_ini_entry *ini_entry; + + buffer_size = 1; + zend_accel_error(ACCEL_LOG_WARNING, "opcache.interned_strings_buffer is set below the required 1MB.\n"); + zend_accel_error(ACCEL_LOG_WARNING, ACCELERATOR_PRODUCT_NAME " will use the minimal 1MB configuration.\n"); + + if (zend_hash_find(EG(ini_directives), + "opcache.interned_strings_buffer", + sizeof("opcache.interned_strings_buffer"), + (void *) &ini_entry) == FAILURE) { + return FAILURE; + } + + ini_entry->value = strdup(new_new_value); + ini_entry->value_length = strlen(new_new_value); + } + *p = buffer_size * 1024 *1024; + return SUCCESS; +} + static ZEND_INI_MH(OnUpdateMaxAcceleratedFiles) { long *p; @@ -256,7 +294,7 @@ ZEND_INI_BEGIN() STD_PHP_INI_ENTRY("opcache.log_verbosity_level" , "1" , PHP_INI_SYSTEM, OnUpdateLong, accel_directives.log_verbosity_level, zend_accel_globals, accel_globals) STD_PHP_INI_ENTRY("opcache.memory_consumption" , "64" , PHP_INI_SYSTEM, OnUpdateMemoryConsumption, accel_directives.memory_consumption, zend_accel_globals, accel_globals) #if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO - STD_PHP_INI_ENTRY("opcache.interned_strings_buffer", "4" , PHP_INI_SYSTEM, OnUpdateLong, accel_directives.interned_strings_buffer, zend_accel_globals, accel_globals) + STD_PHP_INI_ENTRY("opcache.interned_strings_buffer", "4" , PHP_INI_SYSTEM, OnUpdateInternedStringsBuffer, accel_directives.interned_strings_buffer, zend_accel_globals, accel_globals) #endif STD_PHP_INI_ENTRY("opcache.max_accelerated_files" , "2000", PHP_INI_SYSTEM, OnUpdateMaxAcceleratedFiles, accel_directives.max_accelerated_files, zend_accel_globals, accel_globals) STD_PHP_INI_ENTRY("opcache.max_wasted_percentage" , "5" , PHP_INI_SYSTEM, OnUpdateMaxWastedPercentage, accel_directives.max_wasted_percentage, zend_accel_globals, accel_globals) --- a/ZendAccelerator.c +++ b/ZendAccelerator.c @@ -2167,6 +2167,9 @@ static void accel_activate(void) } } + /* The API is enabled by default if opcache.api_password == "" */ + ZCG(accel_directives).api_enabled = (!ZCG(accel_directives).api_password || !*ZCG(accel_directives).api_password); + ZCG(cwd) = NULL; SHM_PROTECT(); @@ -2462,15 +2465,15 @@ static int zend_accel_init_shm(TSRMLS_D) #if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO # ifndef ZTS - zend_hash_init(&ZCSG(interned_strings), (ZCG(accel_directives).interned_strings_buffer * 1024 * 1024) / (sizeof(Bucket) + sizeof(Bucket*) + 8 /* average string length */), NULL, NULL, 1); + zend_hash_init(&ZCSG(interned_strings), ZCG(accel_directives).interned_strings_buffer / (sizeof(Bucket) + sizeof(Bucket*) + 8 /* average string length */), NULL, NULL, 1); ZCSG(interned_strings).nTableMask = ZCSG(interned_strings).nTableSize - 1; ZCSG(interned_strings).arBuckets = zend_shared_alloc(ZCSG(interned_strings).nTableSize * sizeof(Bucket *)); - ZCSG(interned_strings_start) = zend_shared_alloc((ZCG(accel_directives).interned_strings_buffer * 1024 * 1024)); + ZCSG(interned_strings_start) = zend_shared_alloc(ZCG(accel_directives).interned_strings_buffer); if (!ZCSG(interned_strings).arBuckets || !ZCSG(interned_strings_start)) { zend_accel_error(ACCEL_LOG_FATAL, ACCELERATOR_PRODUCT_NAME " cannot allocate buffer for interned strings"); return FAILURE; } - ZCSG(interned_strings_end) = ZCSG(interned_strings_start) + (ZCG(accel_directives).interned_strings_buffer * 1024 * 1024); + ZCSG(interned_strings_end) = ZCSG(interned_strings_start) + ZCG(accel_directives).interned_strings_buffer; ZCSG(interned_strings_top) = ZCSG(interned_strings_start); # else ZCSG(interned_strings_start) = ZCSG(interned_strings_end) = NULL; |
Copyright © 2001-2024 The PHP Group All rights reserved. |
Last updated: Sun Dec 22 01:01:30 2024 UTC |