diff options
Diffstat (limited to 'sapi')
-rw-r--r-- | sapi/aolserver/aolserver.c | 3 | ||||
-rw-r--r-- | sapi/apache/mod_php4.c | 19 | ||||
-rw-r--r-- | sapi/cgi/cgi_main.c | 17 | ||||
-rw-r--r-- | sapi/cgi/getopt.c | 6 | ||||
-rw-r--r-- | sapi/cgi/php_getopt.h | 6 | ||||
-rw-r--r-- | sapi/isapi/php4isapi.c | 3 | ||||
-rw-r--r-- | sapi/phttpd/phttpd.c | 3 | ||||
-rw-r--r-- | sapi/roxen/roxen.c | 3 | ||||
-rw-r--r-- | sapi/servlet/servlet.c | 3 | ||||
-rw-r--r-- | sapi/thttpd/thttpd.c | 3 |
10 files changed, 58 insertions, 8 deletions
diff --git a/sapi/aolserver/aolserver.c b/sapi/aolserver/aolserver.c index eeb3b1c807..7ba56d4e68 100644 --- a/sapi/aolserver/aolserver.c +++ b/sapi/aolserver/aolserver.c @@ -297,6 +297,9 @@ static sapi_module_struct sapi_module = { php_ns_startup, /* startup */ php_module_shutdown_wrapper, /* shutdown */ + NULL, /* activate */ + NULL, /* deactivate */ + php_ns_sapi_ub_write, /* unbuffered write */ NULL, /* flush */ diff --git a/sapi/apache/mod_php4.c b/sapi/apache/mod_php4.c index c7ac6cd8c3..5d05e01f52 100644 --- a/sapi/apache/mod_php4.c +++ b/sapi/apache/mod_php4.c @@ -284,12 +284,31 @@ static void php_apache_log_message(char *message) } +static int php_apache_sapi_activate(SLS_D) +{ + /* + * For the Apache module version, this bit of code registers a cleanup + * function that gets triggered when our request pool is destroyed. + * We need this because at any point in our code we can be interrupted + * and that may happen before we have had time to free our memory. + * The php_request_shutdown function needs to free all outstanding allocated + * memory. + */ + block_alarms(); + register_cleanup(((request_rec *) (server_context))->pool, NULL, php_request_shutdown, php_request_shutdown_for_exec); + unblock_alarms(); +} + + static sapi_module_struct sapi_module = { "Apache", /* name */ php_apache_startup, /* startup */ php_module_shutdown_wrapper, /* shutdown */ + php_apache_sapi_activate, /* activate */ + NULL, /* deactivate */ + sapi_apache_ub_write, /* unbuffered write */ sapi_apache_flush, /* flush */ diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index eb51a9ef95..1d2b5ce653 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -78,8 +78,8 @@ PHPAPI extern char *php_ini_path; #define PHP_MODE_HIGHLIGHT 2 #define PHP_MODE_INDENT 3 -PHPAPI extern char *ap_php_optarg; -PHPAPI extern int ap_php_optind; +extern char *ap_php_optarg; +extern int ap_php_optind; static int sapi_cgibin_ub_write(const char *str, uint str_length) @@ -165,6 +165,16 @@ static void sapi_cgi_log_message(char *message) } } +static int sapi_cgi_activate(SLS_D) +{ + fflush(stdout); + if(request_info.php_argv0) { + free(request_info.php_argv0); + request_info.php_argv0 = NULL; + } + return SUCCESS; +} + static sapi_module_struct sapi_module = { "CGI", /* name */ @@ -172,6 +182,9 @@ static sapi_module_struct sapi_module = { php_module_startup, /* startup */ php_module_shutdown_wrapper, /* shutdown */ + NULL, /* activate */ + sapi_cgi_activate, /* deactivate */ + sapi_cgibin_ub_write, /* unbuffered write */ sapi_cgibin_flush, /* flush */ diff --git a/sapi/cgi/getopt.c b/sapi/cgi/getopt.c index e34356a6b0..4d9187ba8e 100644 --- a/sapi/cgi/getopt.c +++ b/sapi/cgi/getopt.c @@ -10,8 +10,8 @@ #define OPTERRARG (3) -PHPAPI char *ap_php_optarg; -PHPAPI int ap_php_optind = 1; +char *ap_php_optarg; +int ap_php_optind = 1; static int ap_php_opterr = 1; static int ap_php_optopt; @@ -42,7 +42,7 @@ ap_php_optiserr(int argc, char * const *argv, int oint, const char *optstr, return('?'); } -PHPAPI int ap_php_getopt(int argc, char* const *argv, const char *optstr) +int ap_php_getopt(int argc, char* const *argv, const char *optstr) { static int optchr = 0; static int dash = 0; /* have already seen the - */ diff --git a/sapi/cgi/php_getopt.h b/sapi/cgi/php_getopt.h index 5f3af64b64..3b1356d6cd 100644 --- a/sapi/cgi/php_getopt.h +++ b/sapi/cgi/php_getopt.h @@ -1,9 +1,9 @@ /* Borrowed from Apache NT Port */ #include "php.h" -PHPAPI extern char *ap_php_optarg; -PHPAPI extern int ap_php_optind; +extern char *ap_php_optarg; +extern int ap_php_optind; extern int ap_php_opterr; extern int ap_php_optopt; -PHPAPI int ap_php_getopt(int argc, char* const *argv, const char *optstr); +int ap_php_getopt(int argc, char* const *argv, const char *optstr); diff --git a/sapi/isapi/php4isapi.c b/sapi/isapi/php4isapi.c index 83e8c04ad2..9ef51cbb1f 100644 --- a/sapi/isapi/php4isapi.c +++ b/sapi/isapi/php4isapi.c @@ -345,6 +345,9 @@ static sapi_module_struct sapi_module = { php_isapi_startup, /* startup */ php_module_shutdown_wrapper, /* shutdown */ + NULL, /* activate */ + NULL, /* deactivate */ + sapi_isapi_ub_write, /* unbuffered write */ NULL, /* flush */ diff --git a/sapi/phttpd/phttpd.c b/sapi/phttpd/phttpd.c index a766816899..7c98cd70a3 100644 --- a/sapi/phttpd/phttpd.c +++ b/sapi/phttpd/phttpd.c @@ -167,6 +167,9 @@ static sapi_module_struct sapi_module = { php_phttpd_startup, /* startup */ php_module_shutdown_wrapper, /* shutdown */ + NULL, /* activate */ + NULL, /* deactivate */ + php_phttpd_sapi_ub_write, /* unbuffered write */ NULL, /* flush */ diff --git a/sapi/roxen/roxen.c b/sapi/roxen/roxen.c index 7c797667e6..cff4324f9d 100644 --- a/sapi/roxen/roxen.c +++ b/sapi/roxen/roxen.c @@ -521,6 +521,9 @@ static sapi_module_struct sapi_module = { php_module_startup, /* startup */ pike_module_exit, /* shutdown */ + NULL, /* activate */ + NULL, /* deactivate */ + php_roxen_sapi_ub_write, /* unbuffered write */ NULL, /* flush */ diff --git a/sapi/servlet/servlet.c b/sapi/servlet/servlet.c index 3cc4e6e3dc..645528b86c 100644 --- a/sapi/servlet/servlet.c +++ b/sapi/servlet/servlet.c @@ -216,6 +216,9 @@ static sapi_module_struct sapi_module = { php_module_startup, /* startup */ php_module_shutdown_wrapper, /* shutdown */ + NULL, /* activate */ + NULL, /* deactivate */ + sapi_servlet_ub_write, /* unbuffered write */ NULL, /* flush */ diff --git a/sapi/thttpd/thttpd.c b/sapi/thttpd/thttpd.c index 3633475129..2a39f189a4 100644 --- a/sapi/thttpd/thttpd.c +++ b/sapi/thttpd/thttpd.c @@ -107,6 +107,9 @@ static sapi_module_struct sapi_module = { php_module_startup, php_module_shutdown_wrapper, + NULL, /* activate */ + NULL, /* deactivate */ + sapi_thttpd_ub_write, NULL, |