summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2006-05-15 14:52:35 +0000
committerDmitry Stogov <dmitry@php.net>2006-05-15 14:52:35 +0000
commit14cad8fdc377e8e7373456942f2a7b617beb2fb4 (patch)
tree3e22026542d35fcce90a6d9fa37bee6f41115736 /Zend
parentb5cd968ffc8fe71cbf8bf96b84b80883e94f1d2b (diff)
downloadphp-git-14cad8fdc377e8e7373456942f2a7b617beb2fb4.tar.gz
Optimized shutdown sequence to iterate only over modified ini directives
Diffstat (limited to 'Zend')
-rw-r--r--Zend/zend_globals.h2
-rw-r--r--Zend/zend_ini.c27
2 files changed, 26 insertions, 3 deletions
diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h
index 21efa16e0c..ea2d4f219e 100644
--- a/Zend/zend_globals.h
+++ b/Zend/zend_globals.h
@@ -227,6 +227,8 @@ struct _zend_executor_globals {
int lambda_count;
HashTable *ini_directives;
+ HashTable *modified_ini_directives;
+
zend_objects_store objects_store;
zval *exception;
zend_op *opline_before_exception;
diff --git a/Zend/zend_ini.c b/Zend/zend_ini.c
index a9ed9d3e69..056eb03ff8 100644
--- a/Zend/zend_ini.c
+++ b/Zend/zend_ini.c
@@ -65,6 +65,12 @@ static int zend_restore_ini_entry_cb(zend_ini_entry *ini_entry, int stage TSRMLS
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 @@ ZEND_API int zend_ini_startup(TSRMLS_D)
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_global_shutdown(TSRMLS_D)
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 @@ ZEND_API int zend_alter_ini_entry(char *name, uint name_length, char *new_value,
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 @@ ZEND_API int zend_restore_ini_entry(char *name, uint name_length, int stage)
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;
}