zeev Sat Mar 17 15:35:32 2001 EDT
Modified files:
/php4/main main.c php_ini.c php_ini.h
Log:
Recode delayed loading in a much simpler way (switched back to php_ini.c 1.49)
Index: php4/main/main.c
diff -u php4/main/main.c:1.356 php4/main/main.c:1.357
--- php4/main/main.c:1.356 Wed Mar 7 08:33:13 2001
+++ php4/main/main.c Sat Mar 17 15:35:32 2001
@@ -19,7 +19,7 @@
*/
-/* $Id: main.c,v 1.356 2001/03/07 16:33:13 fmk Exp $ */
+/* $Id: main.c,v 1.357 2001/03/17 23:35:32 zeev Exp $ */
#include <stdio.h>
@@ -870,10 +870,7 @@
which is always an internal extension and to be initialized
ahead of all other internals
*/
- if (php_startup_loaded_extensions() == FAILURE) {
- php_printf("Unable to start loaded modules\n");
- return FAILURE;
- }
+ php_ini_delayed_modules_startup();
/* disable certain functions as requested by php.ini */
php_disable_functions();
Index: php4/main/php_ini.c
diff -u php4/main/php_ini.c:1.54 php4/main/php_ini.c:1.55
--- php4/main/php_ini.c:1.54 Tue Mar 6 03:38:55 2001
+++ php4/main/php_ini.c Sat Mar 17 15:35:32 2001
@@ -1,18 +1,18 @@
/*
+----------------------------------------------------------------------+
- | PHP version 4.0 |
+ | PHP version 4.0
+ |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2001 The PHP Group |
+ | Copyright (c) 1997-2001 The PHP Group
+ |
+----------------------------------------------------------------------+
- | This source file is subject to version 2.02 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_02.txt. |
+ | This source file is subject to version 2.02 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available at through the world-wide-web at
+ |
+ | http://www.php.net/license/2_02.txt.
+ |
| If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | [EMAIL PROTECTED] so we can mail you a copy immediately. |
+ | obtain it through the world-wide-web, please send a note to |
+ | [EMAIL PROTECTED] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
- | Author: Zeev Suraski <[EMAIL PROTECTED]> |
+ | Author: Zeev Suraski <[EMAIL PROTECTED]>
+ |
+----------------------------------------------------------------------+
*/
@@ -24,15 +24,19 @@
#include "ext/standard/dl.h"
#include "zend_extensions.h"
-/* True globals */
-static HashTable configuration_hash;
-PHPAPI char *php_ini_opened_path=NULL;
typedef struct _php_extension_lists {
zend_llist engine;
zend_llist functions;
} php_extension_lists;
+
+/* True globals */
+static HashTable configuration_hash;
+PHPAPI char *php_ini_opened_path=NULL;
+static php_extension_lists extension_lists;
+
+
static void php_ini_displayer_cb(zend_ini_entry *ini_entry, int type)
{
if (ini_entry->displayer) {
@@ -121,9 +125,8 @@
}
}
-static void php_config_ini_parser_cb(zval *arg1, zval *arg2, int callback_type, void
*arg_list)
+static void php_config_ini_parser_cb(zval *arg1, zval *arg2, int callback_type, void
+*arg)
{
- php_extension_lists *extension_lists =(php_extension_lists * )arg_list;
switch (callback_type) {
case ZEND_INI_PARSER_ENTRY: {
zval *entry;
@@ -132,12 +135,16 @@
break;
}
if (!strcasecmp(Z_STRVAL_P(arg1), "extension")) { /*
load function module */
- char *extension_name =
estrndup(Z_STRVAL_P(arg2), Z_STRLEN_P(arg2));
-
zend_llist_add_element(&extension_lists->functions, &extension_name);
+ zval copy;
+
+ copy = *arg2;
+ zval_copy_ctor(©);
+ copy.refcount = 0;
+
+zend_llist_add_element(&extension_lists.functions, ©);
} else if (!strcasecmp(Z_STRVAL_P(arg1),
ZEND_EXTENSION_TOKEN)) { /* load Zend extension */
char *extension_name =
estrndup(Z_STRVAL_P(arg2), Z_STRLEN_P(arg2));
-
zend_llist_add_element(&extension_lists->engine, &extension_name);
+
+zend_llist_add_element(&extension_lists.engine, &extension_name);
} else {
zend_hash_update(&configuration_hash,
Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, arg2, sizeof(zval), (void **) &entry);
Z_STRVAL_P(entry) =
zend_strndup(Z_STRVAL_P(entry), Z_STRLEN_P(entry));
@@ -150,35 +157,12 @@
}
-static zend_llist *php_load_extension_list = NULL;
-
-static void php_startup_loaded_extension_cb(void *arg){
- zval *extension, ret;
-
- MAKE_STD_ZVAL(extension);
- ZVAL_STRING(extension,*((char **) arg),0);
- php_dl(extension, MODULE_PERSISTENT, &ret);
- FREE_ZVAL(extension);
-}
-
-int php_startup_loaded_extensions(void)
-{
- if(php_load_extension_list) {
- zend_llist_apply(php_load_extension_list,
php_startup_loaded_extension_cb);
- }
- return SUCCESS;
-}
-
static void php_load_function_extension_cb(void *arg)
{
- char *extension = estrdup(*((char **)arg));
+ zval *extension = (zval *) arg;
+ zval zval;
- if(! php_load_extension_list) {
- php_load_extension_list=(zend_llist*)malloc(sizeof(zend_llist));
- zend_llist_init(php_load_extension_list, sizeof(char **),
(void(*)(void *))free_estring, 1);
- }
-
- zend_llist_add_element(php_load_extension_list, &extension);
+ php_dl(extension, MODULE_PERSISTENT, &zval);
}
@@ -195,24 +179,14 @@
char *open_basedir;
int free_ini_search_path=0;
zend_file_handle fh;
- php_extension_lists extension_lists;
PLS_FETCH();
if (zend_hash_init(&configuration_hash, 0, NULL, (dtor_func_t)
pvalue_config_destructor, 1)==FAILURE) {
return FAILURE;
}
- /* some extensions may be configured by ini entries
- if we would load them right away upon finding an extension
- entry we would have to use the config cache directly as
- the ini mechanism is not finaly initialized yet and we
- would introduce a order dependency in the ini file.
- to avoid this we temporarily store the extensions to
- be loaded in linked lists and process theese immediately
- *after* we have finished setting up the ini mechanism
- */
- zend_llist_init(&extension_lists.engine , sizeof(char **), (void(*)(void
*))free_estring, 1);
- zend_llist_init(&extension_lists.functions, sizeof(char **), (void(*)(void
*))free_estring, 1);
+ zend_llist_init(&extension_lists.engine, sizeof(zval), free_estring, 1);
+ zend_llist_init(&extension_lists.functions, sizeof(zval), ZVAL_DESTRUCTOR, 1);
safe_mode_state = PG(safe_mode);
open_basedir = PG(open_basedir);
@@ -268,15 +242,6 @@
fh.filename = php_ini_opened_path;
zend_parse_ini_file(&fh, 1, php_config_ini_parser_cb, &extension_lists);
-
- /* now that we are done with the configuration settings
- we can load all requested extensions
- */
- zend_llist_apply(&extension_lists.engine, php_load_zend_extension_cb);
- zend_llist_apply(&extension_lists.functions, php_load_function_extension_cb);
-
- zend_llist_destroy(&extension_lists.engine);
- zend_llist_destroy(&extension_lists.functions);
if (php_ini_opened_path) {
zval tmp;
@@ -299,6 +264,16 @@
efree(php_ini_opened_path);
}
return SUCCESS;
+}
+
+
+void php_ini_delayed_modules_startup(void)
+{
+ zend_llist_apply(&extension_lists.engine, php_load_zend_extension_cb);
+ zend_llist_apply(&extension_lists.functions, php_load_function_extension_cb);
+
+ zend_llist_destroy(&extension_lists.engine);
+ zend_llist_destroy(&extension_lists.functions);
}
Index: php4/main/php_ini.h
diff -u php4/main/php_ini.h:1.33 php4/main/php_ini.h:1.34
--- php4/main/php_ini.h:1.33 Sun Feb 25 22:07:31 2001
+++ php4/main/php_ini.h Sat Mar 17 15:35:32 2001
@@ -23,7 +23,7 @@
int php_init_config(char *php_ini_path_override);
int php_shutdown_config(void);
-int php_startup_loaded_extensions(void);
+void php_ini_delayed_modules_startup(void);
zval *cfg_get_entry(char *name, uint name_length);
#define PHP_INI_USER ZEND_INI_USER
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]