1
0
mirror of https://github.com/php/php-src.git synced 2026-04-09 00:53:30 +02:00

will now initialize dynamic extensions *after* static ones

This commit is contained in:
Hartmut Holzgraefe
2001-02-21 01:43:15 +00:00
parent c685f25d33
commit b14d2cc0dc
2 changed files with 79 additions and 21 deletions

View File

@@ -818,17 +818,27 @@ int php_module_startup(sapi_module_struct *sf)
le_index_ptr = zend_register_list_destructors_ex(NULL, NULL, "index pointer", 0);
/* this will read in php.ini, set up the configuration parameters,
load zend extensions and register php function extensions
to be loaded later */
if (php_init_config(sf->php_ini_path_override) == FAILURE) {
return FAILURE;
}
REGISTER_INI_ENTRIES();
/* initialize fopen wrappers registry
(this uses configuration parameters from php.ini)
*/
if (php_init_fopen_wrappers() == FAILURE) {
php_printf("PHP: Unable to initialize fopen url wrappers.\n");
return FAILURE;
}
/* initialize registry for images to be used in phpinfo()
(this uses configuration parameters from php.ini)
*/
if (php_init_info_logos() == FAILURE) {
php_printf("PHP: Unable to initialize info phpinfo logos.\n");
return FAILURE;
@@ -846,14 +856,34 @@ int php_module_startup(sapi_module_struct *sf)
return FAILURE;
}
/* startup extensions staticly compiled in */
if (php_startup_internal_extensions() == FAILURE) {
php_printf("Unable to start builtin modules\n");
return FAILURE;
}
/* load and startup extensions compiled as shared objects (aka DLLs)
as requested by php.ini entries
theese are loaded after initialization of internal extensions
as extensions *might* rely on things from ext/standard
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;
}
/* disable certain functions as requested by php.ini */
php_disable_functions();
zend_startup_extensions();
/* */
module_initialized = 1;
sapi_deactivate(SLS_C);
/* we're done */
return SUCCESS;
}

View File

@@ -1,18 +1,18 @@
/*
+----------------------------------------------------------------------+
| PHP version 4.0 |
| PHP version 4.0 |
+----------------------------------------------------------------------+
| Copyright (c) 1997, 1998, 1999, 2000 The PHP Group |
| Copyright (c) 1997, 1998, 1999, 2000 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 |
| license@php.net so we can mail you a copy immediately. |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Zeev Suraski <zeev@zend.com> |
| Author: Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
*/
@@ -131,12 +131,8 @@ static void php_config_ini_parser_cb(zval *arg1, zval *arg2, int callback_type,
break;
}
if (!strcasecmp(Z_STRVAL_P(arg1), "extension")) { /* load function module */
zval copy;
copy = *arg2;
zval_copy_ctor(&copy);
copy.refcount = 0;
zend_llist_add_element(&extension_lists->functions, &copy);
char *extension_name = estrndup(Z_STRVAL_P(arg2), Z_STRLEN_P(arg2));
zend_llist_add_element(&extension_lists->functions, &extension_name);
} 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));
@@ -153,12 +149,32 @@ static void php_config_ini_parser_cb(zval *arg1, zval *arg2, int callback_type,
}
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)
{
zend_llist_apply(php_load_extension_list, php_startup_loaded_extension_cb);
}
static void php_load_function_extension_cb(void *arg)
{
zval *extension = (zval *) arg;
zval zval;
char *extension = estrdup(*((char **)arg));
php_dl(extension, MODULE_PERSISTENT, &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 **), free_estring, 1);
}
zend_llist_add_element(php_load_extension_list, &extension);
}
@@ -182,8 +198,17 @@ int php_init_config(char *php_ini_path_override)
return FAILURE;
}
zend_llist_init(&extension_lists.engine, sizeof(zval), free_estring, 1);
zend_llist_init(&extension_lists.functions, sizeof(zval), ZVAL_DESTRUCTOR, 1);
/* 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 **), free_estring, 1);
zend_llist_init(&extension_lists.functions, sizeof(char **), free_estring, 1);
safe_mode_state = PG(safe_mode);
open_basedir = PG(open_basedir);
@@ -236,9 +261,12 @@ int php_init_config(char *php_ini_path_override)
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);