Re: cvs: php4 /main main.c php_ini.c

From: Date: Wed, 21 Feb 2001 02:51:43 +0000
Subject: Re: cvs: php4 /main main.c php_ini.c
References: 1  Groups: php.cvs 
Request: Send a blank email to php-cvs+get-4172@lists.php.net to get a copy of this message
Wouldn't that happen even without the patch? I'd imagine the dynamic extensions would be last on the list..? Zeev At 20:43 20/2/2001, Hartmut Holzgraefe wrote:
hholzgra                Tue Feb 20 17:43:15 2001 EDT
Modified files:
    /php4/main  main.c php_ini.c
Log: will now initialize dynamic extensions *after* static ones Index: php4/main/main.c diff -u php4/main/main.c:1.349 php4/main/main.c:1.350
--- php4/main/main.c:1.349      Sat Jan 13 05:16:56 2001
+++ php4/main/main.c    Tue Feb 20 17:43:15 2001
@@ -19,7 +19,7 @@ */ -/* $Id: main.c,v 1.349 2001/01/13 13:16:56 zeev Exp $ */ +/* $Id: main.c,v 1.350 2001/02/21 01:43:15 hholzgra Exp $ */ #include <stdio.h> @@ -818,17 +818,27 @@
        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 @@
                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;
} Index: php4/main/php_ini.c diff -u php4/main/php_ini.c:1.49 php4/main/php_ini.c:1.50
--- php4/main/php_ini.c:1.49    Mon Jan 15 02:52:02 2001
+++ php4/main/php_ini.c Tue Feb 20 17:43:15 2001 @@ -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 @@
                                        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 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 @@
                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 @@
        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);
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-cvs-unsubscribe@lists.php.net For additional commands, e-mail: php-cvs-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net
-- Zeev Suraski <zeev@zend.com> CTO & co-founder, Zend Technologies Ltd. http://www.zend.com/

« previous php.cvs (#4172) next »