cvs: ZendEngine2(PHP_5_2) / zend_globals.h zend_ini.c

From: Date: Mon, 15 May 2006 14:52:35 +0000
Subject: cvs: ZendEngine2(PHP_5_2) / zend_globals.h zend_ini.c
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-4881@lists.php.net to get a copy of this message
dmitry Mon May 15 14:52:35 2006 UTC Modified files: (Branch: PHP_5_2) /ZendEngine2 zend_globals.h zend_ini.c Log: Optimized shutdown sequence to iterate only over modified ini directives http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_globals.h?r1=1.141.2.3.2.1&r2=1.141.2.3.2.2&diff_format=u Index: ZendEngine2/zend_globals.h diff -u ZendEngine2/zend_globals.h:1.141.2.3.2.1 ZendEngine2/zend_globals.h:1.141.2.3.2.2 --- ZendEngine2/zend_globals.h:1.141.2.3.2.1 Tue May 9 23:53:23 2006 +++ ZendEngine2/zend_globals.h Mon May 15 14:52:35 2006 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_globals.h,v 1.141.2.3.2.1 2006/05/09 23:53:23 helly Exp $ */ +/* $Id: zend_globals.h,v 1.141.2.3.2.2 2006/05/15 14:52:35 dmitry Exp $ */ #ifndef ZEND_GLOBALS_H #define ZEND_GLOBALS_H @@ -227,6 +227,8 @@ int lambda_count; HashTable *ini_directives; + HashTable *modified_ini_directives; + zend_objects_store objects_store; zval *exception; zend_op *opline_before_exception; http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_ini.c?r1=1.39.2.2&r2=1.39.2.2.2.1&diff_format=u Index: ZendEngine2/zend_ini.c diff -u ZendEngine2/zend_ini.c:1.39.2.2 ZendEngine2/zend_ini.c:1.39.2.2.2.1 --- ZendEngine2/zend_ini.c:1.39.2.2 Wed Jan 4 23:53:04 2006 +++ ZendEngine2/zend_ini.c Mon May 15 14:52:35 2006 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_ini.c,v 1.39.2.2 2006/01/04 23:53:04 andi Exp $ */ +/* $Id: zend_ini.c,v 1.39.2.2.2.1 2006/05/15 14:52:35 dmitry Exp $ */ #include "zend.h" #include "zend_qsort.h" @@ -65,6 +65,12 @@ return 0; } +static int zend_restore_ini_entry_wrapper(zend_ini_entry **ini_entry TSRMLS_DC) +{ + zend_restore_ini_entry_cb(*ini_entry, ZEND_INI_STAGE_DEACTIVATE TSRMLS_CC); + return 1; +} + /* * Startup / shutdown */ @@ -73,6 +79,7 @@ registered_zend_ini_directives = (HashTable *) malloc(sizeof(HashTable)); EG(ini_directives) = registered_zend_ini_directives; + EG(modified_ini_directives) = NULL; if (zend_hash_init_ex(registered_zend_ini_directives, 100, NULL, NULL, 1, 0)==FAILURE) { return FAILURE; } @@ -98,7 +105,12 @@ ZEND_API int zend_ini_deactivate(TSRMLS_D) { - zend_hash_apply_with_argument(EG(ini_directives), (apply_func_arg_t) zend_restore_ini_entry_cb, (void *) ZEND_INI_STAGE_DEACTIVATE TSRMLS_CC); + if (EG(modified_ini_directives)) { + zend_hash_apply(EG(modified_ini_directives), (apply_func_t) zend_restore_ini_entry_wrapper TSRMLS_CC); + zend_hash_destroy(EG(modified_ini_directives)); + FREE_HASHTABLE(EG(modified_ini_directives)); + EG(modified_ini_directives) = NULL; + } return SUCCESS; } @@ -237,12 +249,17 @@ if (!ini_entry->modified) { ini_entry->orig_value = ini_entry->value; ini_entry->orig_value_length = ini_entry->value_length; + ini_entry->modified = 1; + if (!EG(modified_ini_directives)) { + ALLOC_HASHTABLE(EG(modified_ini_directives)); + zend_hash_init(EG(modified_ini_directives), 8, NULL, NULL, 0); + } + zend_hash_add(EG(modified_ini_directives), name, name_length, &ini_entry, sizeof(zend_ini_entry*), NULL); } else { /* we already changed the value, free the changed value */ efree(ini_entry->value); } ini_entry->value = duplicate; ini_entry->value_length = new_value_length; - ini_entry->modified = 1; } else { efree(duplicate); } @@ -260,7 +277,11 @@ return FAILURE; } - zend_restore_ini_entry_cb(ini_entry, stage TSRMLS_CC); + if (EG(modified_ini_directives)) { + zend_restore_ini_entry_cb(ini_entry, stage TSRMLS_CC); + zend_hash_del(EG(modified_ini_directives), name, name_length); + } + return SUCCESS; }

« previous php.zend-engine.cvs (#4881) next »