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...
This commit is contained in:
Zeev Suraski 2002-09-18 21:57:42 +00:00
parent 70f17979fb
commit 76312b4508
20 changed files with 109 additions and 45 deletions

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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,

View File

@ -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 */

View File

@ -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,

View File

@ -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

View File

@ -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;
}

View File

@ -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

View File

@ -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");

View File

@ -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 */

View File

@ -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;

View File

@ -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;

View File

@ -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();
}

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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 */

View File

@ -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;