cvs: ZendEngine2 / zend_globals.h zend_ini.c
| From: | Dmitry Stogov | Date: | Mon, 15 May 2006 14:53:47 +0000 |
| Subject: | cvs: ZendEngine2 / zend_globals.h zend_ini.c | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-4882@lists.php.net to get a copy of this message | ||
dmitry Mon May 15 14:53:47 2006 UTC
Modified files:
/ZendEngine2 zend_globals.h zend_ini.c
Log:
Optimized request shutdown sequence to iterate only over modified ini directives
http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_globals.h?r1=1.157&r2=1.158&diff_format=u
Index: ZendEngine2/zend_globals.h
diff -u ZendEngine2/zend_globals.h:1.157 ZendEngine2/zend_globals.h:1.158
--- ZendEngine2/zend_globals.h:1.157 Thu May 4 21:22:17 2006
+++ ZendEngine2/zend_globals.h Mon May 15 14:53:47 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_globals.h,v 1.157 2006/05/04 21:22:17 andrei Exp $ */
+/* $Id: zend_globals.h,v 1.158 2006/05/15 14:53:47 dmitry Exp $ */
#ifndef ZEND_GLOBALS_H
#define ZEND_GLOBALS_H
@@ -220,6 +220,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.45&r2=1.46&diff_format=u
Index: ZendEngine2/zend_ini.c
diff -u ZendEngine2/zend_ini.c:1.45 ZendEngine2/zend_ini.c:1.46
--- ZendEngine2/zend_ini.c:1.45 Tue Feb 21 20:12:41 2006
+++ ZendEngine2/zend_ini.c Mon May 15 14:53:47 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_ini.c,v 1.45 2006/02/21 20:12:41 dmitry Exp $ */
+/* $Id: zend_ini.c,v 1.46 2006/05/15 14:53:47 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;
}
@@ -238,12 +250,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);
}
@@ -261,7 +278,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;
}