From 76312b4508b43ed2cebd97b749e9e90181e55073 Mon Sep 17 00:00:00 2001 From: Zeev Suraski Date: Wed, 18 Sep 2002 21:57:42 +0000 Subject: [PATCH] another startup initialization fix - only ISAPI and CGI SAPI's tested, minor compile buglets might occur in other SAPIs, but should be trivial to fix... --- main/main.c | 6 +++++- main/php_main.h | 2 +- sapi/activescript/php4activescript.c | 3 +-- sapi/aolserver/aolserver.c | 3 +-- sapi/apache/mod_php4.c | 3 +-- sapi/apache2filter/php_functions.c | 2 +- sapi/apache2filter/sapi_apache2.c | 13 ++++++++++++- sapi/caudium/caudium.c | 13 +++++++++++-- sapi/cgi/cgi_main.c | 13 +++++++++++-- sapi/cli/php_cli.c | 14 ++++++++++++-- sapi/fastcgi/fastcgi.c | 13 +++++++++++-- sapi/isapi/php4isapi.c | 3 +-- sapi/nsapi/nsapi.c | 11 ++++++++++- sapi/phttpd/phttpd.c | 6 +----- sapi/pi3web/pi3web_sapi.c | 3 +-- sapi/roxen/roxen.c | 7 +++---- sapi/servlet/servlet.c | 20 ++++++++++++-------- sapi/thttpd/thttpd.c | 3 +-- sapi/tux/php_tux.c | 12 +++++++++++- sapi/webjames/webjames.c | 4 ++-- 20 files changed, 109 insertions(+), 45 deletions(-) diff --git a/main/main.c b/main/main.c index 18d83c10fa215..1306414dd0f38 100644 --- a/main/main.c +++ b/main/main.c @@ -966,7 +966,7 @@ int php_startup_extensions(zend_module_entry **ptr, int count) /* {{{ php_module_startup */ -int php_module_startup(sapi_module_struct *sf) +int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_modules, uint num_additional_modules) { zend_utility_functions zuf; zend_utility_values zuv; @@ -1118,6 +1118,9 @@ int php_module_startup(sapi_module_struct *sf) php_printf("Unable to start builtin modules\n"); return FAILURE; } + /* start additional PHP extensions */ + php_startup_extensions(&additional_modules, num_additional_modules); + /* load and startup extensions compiled as shared objects (aka DLLs) as requested by php.ini entries @@ -1131,6 +1134,7 @@ int php_module_startup(sapi_module_struct *sf) /* disable certain functions as requested by php.ini */ php_disable_functions(TSRMLS_C); + /* start Zend extensions */ zend_startup_extensions(); #ifdef ZTS diff --git a/main/php_main.h b/main/php_main.h index 1e16496ca8f62..dcf249020e402 100644 --- a/main/php_main.h +++ b/main/php_main.h @@ -31,7 +31,7 @@ PHPAPI int php_request_startup(TSRMLS_D); PHPAPI void php_request_shutdown(void *dummy); PHPAPI void php_request_shutdown_for_exec(void *dummy); -PHPAPI int php_module_startup(sapi_module_struct *sf); +PHPAPI int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_modules, uint num_additional_modules); PHPAPI void php_module_shutdown(TSRMLS_D); PHPAPI void php_module_shutdown_for_exec(void); PHPAPI int php_module_shutdown_wrapper(sapi_module_struct *sapi_globals); diff --git a/sapi/activescript/php4activescript.c b/sapi/activescript/php4activescript.c index eed1d7e52eb17..a85cd625b9861 100644 --- a/sapi/activescript/php4activescript.c +++ b/sapi/activescript/php4activescript.c @@ -30,8 +30,7 @@ static int php_activescript_startup(sapi_module_struct *sapi_module) { - if (php_module_startup(sapi_module) == FAILURE || - zend_startup_module(&php_activescript_module) == FAILURE) { + if (php_module_startup(sapi_module, &php_activescript_module, 1) == FAILURE) { return FAILURE; } else { return SUCCESS; diff --git a/sapi/aolserver/aolserver.c b/sapi/aolserver/aolserver.c index 0ce52e4c004e5..3131d69d712e2 100644 --- a/sapi/aolserver/aolserver.c +++ b/sapi/aolserver/aolserver.c @@ -277,8 +277,7 @@ PHP_FUNCTION(getallheaders) static int php_ns_startup(sapi_module_struct *sapi_module) { - if(php_module_startup(sapi_module) == FAILURE - || zend_startup_module(&php_aolserver_module) == FAILURE) { + if (php_module_startup(sapi_module, &php_aolserver_module, 1) == FAILURE) { return FAILURE; } else { return SUCCESS; diff --git a/sapi/apache/mod_php4.c b/sapi/apache/mod_php4.c index 26573a6065741..bbc95fb7ed776 100644 --- a/sapi/apache/mod_php4.c +++ b/sapi/apache/mod_php4.c @@ -256,8 +256,7 @@ static void sapi_apache_register_server_variables(zval *track_vars_array TSRMLS_ */ static int php_apache_startup(sapi_module_struct *sapi_module) { - if (php_module_startup(sapi_module) == FAILURE - || zend_startup_module(&apache_module_entry) == FAILURE) { + if (php_module_startup(sapi_module, &apache_module_entry, 1) == FAILURE) { return FAILURE; } else { return SUCCESS; diff --git a/sapi/apache2filter/php_functions.c b/sapi/apache2filter/php_functions.c index c04e0b938eddc..e7631266b2134 100644 --- a/sapi/apache2filter/php_functions.c +++ b/sapi/apache2filter/php_functions.c @@ -154,7 +154,7 @@ static function_entry apache_functions[] = { {NULL, NULL, NULL} }; -static zend_module_entry php_apache_module = { +zend_module_entry php_apache_module = { STANDARD_MODULE_HEADER, "Apache 2.0", apache_functions, diff --git a/sapi/apache2filter/sapi_apache2.c b/sapi/apache2filter/sapi_apache2.c index 9a63da69223b8..c8589e39ffe14 100644 --- a/sapi/apache2filter/sapi_apache2.c +++ b/sapi/apache2filter/sapi_apache2.c @@ -230,11 +230,22 @@ static void php_apache_sapi_log_message(char *msg) } } + +extern zend_module_entry php_apache_module; + +static int php_apache2_startup(sapi_module_struct *sapi_module) +{ + if (php_module_startup(sapi_module, &php_apache_module, 1)==FAILURE) { + return FAILURE; + } + return SUCCESS; +} + static sapi_module_struct apache2_sapi_module = { "apache2filter", "Apache 2.0 Filter", - php_module_startup, /* startup */ + php_apache2_startup, /* startup */ php_module_shutdown_wrapper, /* shutdown */ NULL, /* activate */ diff --git a/sapi/caudium/caudium.c b/sapi/caudium/caudium.c index f0f0284ed23cc..319670f039fae 100644 --- a/sapi/caudium/caudium.c +++ b/sapi/caudium/caudium.c @@ -520,11 +520,21 @@ static void sapi_caudium_register_variables(zval *track_vars_array TSRMLS_DC) THREAD_SAFE_RUN(low_sapi_caudium_register_variables(track_vars_array TSRMLS_CC), "register_variables"); } + +static int php_caudium_startup(sapi_module_struct *sapi_module) +{ + if (php_module_startup(sapi_module, &php_caudium_module, 1)==FAILURE) { + return FAILURE; + } + return SUCCESS; +} + + /* this structure is static (as in "it does not change") */ static sapi_module_struct caudium_sapi_module = { "caudium", "Caudium", - php_module_startup, /* startup */ + php_caudium_startup, /* startup */ php_module_shutdown_wrapper, /* shutdown */ NULL, /* activate */ NULL, /* deactivate */ @@ -762,7 +772,6 @@ void pike_module_init( void ) ts_allocate_id(&caudium_globals_id, sizeof(php_caudium_request), NULL, NULL); sapi_startup(&caudium_sapi_module); sapi_module.startup(&caudium_sapi_module); - zend_startup_module(&php_caudium_module); } start_new_program(); /* Text */ pike_add_function("run", f_php_caudium_request_handler, diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index 28bfb21c893f7..29ef0025b5472 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -296,6 +296,15 @@ static int sapi_cgi_deactivate(TSRMLS_D) } +static int php_cgi_startup(sapi_module_struct *sapi_module) +{ + if (php_module_startup(sapi_module, NULL, 0)==FAILURE) { + return FAILURE; + } + return SUCCESS; +} + + /* {{{ sapi_module_struct cgi_sapi_module */ static sapi_module_struct cgi_sapi_module = { @@ -306,7 +315,7 @@ static sapi_module_struct cgi_sapi_module = { "CGI", /* pretty name */ #endif - php_module_startup, /* startup */ + php_cgi_startup, /* startup */ php_module_shutdown_wrapper, /* shutdown */ NULL, /* activate */ @@ -591,7 +600,7 @@ int main(int argc, char *argv[]) cgi_sapi_module.executable_location = argv[0]; /* startup after we get the above ini override se we get things right */ - if (php_module_startup(&cgi_sapi_module)==FAILURE) { + if (php_module_startup(&cgi_sapi_module, NULL, 0)==FAILURE) { #ifdef ZTS tsrm_shutdown(); #endif diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index cf7ef0725df34..ddfa66163b122 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -200,13 +200,23 @@ static void sapi_cli_send_header(sapi_header_struct *sapi_header, void *server_c PHPWRITE_H("\r\n", 2); } + +static int php_cli_startup(sapi_module_struct *sapi_module) +{ + if (php_module_startup(sapi_module, NULL, 0)==FAILURE) { + return FAILURE; + } + return SUCCESS; +} + + /* {{{ sapi_module_struct cli_sapi_module */ static sapi_module_struct cli_sapi_module = { "cli", /* name */ "Command Line Interface", /* pretty name */ - php_module_startup, /* startup */ + php_cli_startup, /* startup */ php_module_shutdown_wrapper, /* shutdown */ NULL, /* activate */ @@ -421,7 +431,7 @@ int main(int argc, char *argv[]) cli_sapi_module.executable_location = argv[0]; /* startup after we get the above ini override se we get things right */ - if (php_module_startup(&cli_sapi_module)==FAILURE) { + if (php_module_startup(&cli_sapi_module, NULL, 0)==FAILURE) { return FAILURE; } diff --git a/sapi/fastcgi/fastcgi.c b/sapi/fastcgi/fastcgi.c index ccf57eb308f08..23fd8c0aec2d9 100644 --- a/sapi/fastcgi/fastcgi.c +++ b/sapi/fastcgi/fastcgi.c @@ -174,11 +174,20 @@ static void sapi_fastcgi_log_message(char *message) } +static int php_fastcgi_startup(sapi_module_struct *sapi_module) +{ + if (php_module_startup(sapi_module, NULL, 0)==FAILURE) { + return FAILURE; + } + return SUCCESS; +} + + static sapi_module_struct fastcgi_sapi_module = { "fastcgi", "FastCGI", - php_module_startup, + php_fastcgi_startup, php_module_shutdown_wrapper, NULL, /* activate */ @@ -444,7 +453,7 @@ int main(int argc, char *argv[]) setmode(_fileno(stderr), O_BINARY); /* make the stdio mode be binary */ #endif - if (php_module_startup(&fastcgi_sapi_module)==FAILURE) { + if (php_module_startup(&fastcgi_sapi_module, NULL, 0)==FAILURE) { return FAILURE; } #ifdef ZTS diff --git a/sapi/isapi/php4isapi.c b/sapi/isapi/php4isapi.c index 129c345f694d4..9f2d3f296d173 100644 --- a/sapi/isapi/php4isapi.c +++ b/sapi/isapi/php4isapi.c @@ -296,8 +296,7 @@ static int sapi_isapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) static int php_isapi_startup(sapi_module_struct *sapi_module) { - if (php_module_startup(sapi_module)==FAILURE - || zend_startup_module(&php_isapi_module)==FAILURE) { + if (php_module_startup(sapi_module, &php_isapi_module, 1)==FAILURE) { return FAILURE; } else { bTerminateThreadsOnError = (zend_bool) INI_INT("isapi.terminate_threads_on_error"); diff --git a/sapi/nsapi/nsapi.c b/sapi/nsapi/nsapi.c index 2a392ac434b7c..522df344797df 100644 --- a/sapi/nsapi/nsapi.c +++ b/sapi/nsapi/nsapi.c @@ -342,11 +342,20 @@ nsapi_log_message(char *message) } +static int php_nsapi_startup(sapi_module_struct *sapi_module) +{ + if (php_module_startup(sapi_module, NULL, 0)==FAILURE) { + return FAILURE; + } + return SUCCESS; +} + + static sapi_module_struct nsapi_sapi_module = { "nsapi", /* name */ "NSAPI", /* pretty name */ - php_module_startup, /* startup */ + php_nsapi_startup, /* startup */ php_module_shutdown_wrapper, /* shutdown */ NULL, /* activate */ diff --git a/sapi/phttpd/phttpd.c b/sapi/phttpd/phttpd.c index 7e7367d49d5eb..415c691cc76da 100644 --- a/sapi/phttpd/phttpd.c +++ b/sapi/phttpd/phttpd.c @@ -43,13 +43,9 @@ static int ph_globals_id; static int php_phttpd_startup(sapi_module_struct *sapi_module) { -/* - if(php_module_startup(sapi_module) == FAILURE - || zend_startup_module(&php_aolserver_module) == FAILURE) { -*/ fprintf(stderr,"***php_phttpd_startup\n"); - if (php_module_startup(sapi_module)) { + if (php_module_startup(sapi_module, NULL, 0)) { return FAILURE; } else { return SUCCESS; diff --git a/sapi/pi3web/pi3web_sapi.c b/sapi/pi3web/pi3web_sapi.c index 873e92127bc95..e4b782f4f17af 100644 --- a/sapi/pi3web/pi3web_sapi.c +++ b/sapi/pi3web/pi3web_sapi.c @@ -215,8 +215,7 @@ static int sapi_pi3web_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) static int php_pi3web_startup(sapi_module_struct *sapi_module) { - if (php_module_startup(sapi_module)==FAILURE - || zend_register_module(&php_pi3web_module)==FAILURE) { + if (php_module_startup(sapi_module, &php_pi3web_module, 1)==FAILURE) { return FAILURE; } else { return SUCCESS; diff --git a/sapi/roxen/roxen.c b/sapi/roxen/roxen.c index 400fdc65074e1..d86bb0917c2cd 100644 --- a/sapi/roxen/roxen.c +++ b/sapi/roxen/roxen.c @@ -473,8 +473,7 @@ static zend_module_entry php_roxen_module = { static int php_roxen_startup(sapi_module_struct *sapi_module) { - if(php_module_startup(sapi_module) == FAILURE - || zend_startup_module(&php_roxen_module) == FAILURE) { + if(php_module_startup(sapi_module, &php_roxen_module) == FAILURE) { return FAILURE; } else { return SUCCESS; @@ -486,7 +485,7 @@ static int php_roxen_startup(sapi_module_struct *sapi_module) static sapi_module_struct roxen_sapi_module = { "roxen", "Roxen", - php_module_startup, /* startup */ + php_roxen_startup, /* startup */ php_module_shutdown_wrapper, /* shutdown */ NULL, /* activate */ NULL, /* deactivate */ @@ -698,7 +697,7 @@ void pike_module_init( void ) #endif #endif sapi_startup(&roxen_sapi_module); - php_roxen_startup(&roxen_sapi_module); + /*php_roxen_startup(&roxen_sapi_module); removed - should be called from SAPI activation*/ roxen_php_initialized = 1; PHP_INIT_LOCK(); } diff --git a/sapi/servlet/servlet.c b/sapi/servlet/servlet.c index 727dd9fe94148..538a603f8c7f9 100644 --- a/sapi/servlet/servlet.c +++ b/sapi/servlet/servlet.c @@ -205,15 +205,25 @@ static char *sapi_servlet_read_cookies(TSRMLS_D) /***************************************************************************/ + /* * sapi maintenance */ +static int php_servlet_startup(sapi_module_struct *sapi_module) +{ + if (php_module_startup(sapi_module, NULL, 0)==FAILURE) { + return FAILURE; + } else { + return SUCCESS; + } +} + static sapi_module_struct servlet_sapi_module = { "java_servlet", /* name */ "Java Servlet", /* pretty name */ - php_module_startup, /* startup */ + php_servlet_startup, /* startup */ php_module_shutdown_wrapper, /* shutdown */ NULL, /* activate */ @@ -253,16 +263,10 @@ JNIEXPORT void JNICALL Java_net_php_servlet_startup sapi_startup(&servlet_sapi_module); - if (php_module_startup(&servlet_sapi_module)==FAILURE) { + if (php_module_startup(&servlet_sapi_module, additional_php_extensions, EXTCOUNT)==FAILURE) { ThrowServletException(jenv,"module startup failure"); return; } - - if (php_startup_extensions(additional_php_extensions, EXTCOUNT)==FAILURE) { - ThrowServletException(jenv,"extension startup failure"); - return; - } - } diff --git a/sapi/thttpd/thttpd.c b/sapi/thttpd/thttpd.c index 1cda5a34f4e44..896b4d7161582 100644 --- a/sapi/thttpd/thttpd.c +++ b/sapi/thttpd/thttpd.c @@ -355,8 +355,7 @@ static zend_module_entry php_thttpd_module = { static int php_thttpd_startup(sapi_module_struct *sapi_module) { - if (php_module_startup(sapi_module) == FAILURE - || zend_startup_module(&php_thttpd_module) == FAILURE) { + if (php_module_startup(sapi_module, &php_thttpd_module, 1) == FAILURE) { return FAILURE; } return SUCCESS; diff --git a/sapi/tux/php_tux.c b/sapi/tux/php_tux.c index 4f0b6e17db8b4..0c0384de25191 100644 --- a/sapi/tux/php_tux.c +++ b/sapi/tux/php_tux.c @@ -252,11 +252,21 @@ static void sapi_tux_register_variables(zval *track_vars_array TSRMLS_DC) #endif } + +static int php_tux_startup(sapi_module_struct *sapi_module) +{ + if (php_module_startup(sapi_module, NULL, 0)==FAILURE) { + return FAILURE; + } else { + return SUCCESS; + } +} + static sapi_module_struct tux_sapi_module = { "tux", "tux", - php_module_startup, + php_tux_startup, php_module_shutdown_wrapper, NULL, /* activate */ diff --git a/sapi/webjames/webjames.c b/sapi/webjames/webjames.c index 3bea3457e48fc..9d2f25013aecd 100644 --- a/sapi/webjames/webjames.c +++ b/sapi/webjames/webjames.c @@ -242,10 +242,10 @@ static zend_module_entry php_webjames_module = { STANDARD_MODULE_PROPERTIES }; + static int php_webjames_startup(sapi_module_struct *sapi_module) { - if(php_module_startup(sapi_module) == FAILURE - || zend_startup_module(&php_webjames_module) == FAILURE) { + if(php_module_startup(sapi_module, &php_webjames_module, 1) == FAILURE) { return FAILURE; } else { return SUCCESS;