Skip to content

Commit

Permalink
another startup initialization fix - only ISAPI and CGI SAPI's tested,
Browse files Browse the repository at this point in the history
minor compile buglets might occur in other SAPIs, but should be trivial
to fix...
  • Loading branch information
zsuraski committed Sep 18, 2002
1 parent 70f1797 commit 76312b4
Show file tree
Hide file tree
Showing 20 changed files with 109 additions and 45 deletions.
6 changes: 5 additions & 1 deletion main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion main/php_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions sapi/activescript/php4activescript.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions sapi/aolserver/aolserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions sapi/apache/mod_php4.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion sapi/apache2filter/php_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 12 additions & 1 deletion sapi/apache2filter/sapi_apache2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
13 changes: 11 additions & 2 deletions sapi/caudium/caudium.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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,
Expand Down
13 changes: 11 additions & 2 deletions sapi/cgi/cgi_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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 */
Expand Down Expand Up @@ -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
Expand Down
14 changes: 12 additions & 2 deletions sapi/cli/php_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
}

Expand Down
13 changes: 11 additions & 2 deletions sapi/fastcgi/fastcgi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions sapi/isapi/php4isapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
11 changes: 10 additions & 1 deletion sapi/nsapi/nsapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
6 changes: 1 addition & 5 deletions sapi/phttpd/phttpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions sapi/pi3web/pi3web_sapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 3 additions & 4 deletions sapi/roxen/roxen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 */
Expand Down Expand Up @@ -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();
}
Expand Down
20 changes: 12 additions & 8 deletions sapi/servlet/servlet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
}

}


Expand Down
3 changes: 1 addition & 2 deletions sapi/thttpd/thttpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 11 additions & 1 deletion sapi/tux/php_tux.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
Loading

0 comments on commit 76312b4

Please sign in to comment.