summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeev Suraski <zeev@php.net>2000-02-13 00:26:54 +0000
committerZeev Suraski <zeev@php.net>2000-02-13 00:26:54 +0000
commit003ef1aa7479e9f6854397624764bdf6a6b1737f (patch)
tree0ac2e60aeb8d25640e42095d49a18198c6442ad8
parentbbb25255b03703c8a940bf357d0ac8609ff9036e (diff)
downloadphp-git-003ef1aa7479e9f6854397624764bdf6a6b1737f.tar.gz
Trap bailout of shutdown functions
-rw-r--r--ext/standard/basic_functions.c17
-rw-r--r--main/main.c6
-rw-r--r--main/php_globals.h1
3 files changed, 16 insertions, 8 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index f5c571a21a..61a6a27cd2 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -1053,6 +1053,7 @@ void user_shutdown_function_dtor(php_shutdown_function_entry *shutdown_function_
efree(shutdown_function_entry->arguments);
}
+
int user_shutdown_function_call(php_shutdown_function_entry *shutdown_function_entry)
{
zval retval;
@@ -1060,19 +1061,31 @@ int user_shutdown_function_call(php_shutdown_function_entry *shutdown_function_e
if (call_user_function(CG(function_table), NULL, shutdown_function_entry->arguments[0], &retval, shutdown_function_entry->arg_count-1, shutdown_function_entry->arguments+1)==SUCCESS) {
zval_dtor(&retval);
- } else
+ } else {
php_error(E_WARNING,"Unable to call %s() - function does not exist",
shutdown_function_entry->arguments[0]->value.str.val);
+ }
return 0;
}
+
void php_call_shutdown_functions(void)
{
BLS_FETCH();
-
+ ELS_FETCH();
+
if (BG(user_shutdown_function_names)) {
+ jmp_buf orig_bailout;
+
+ memcpy(&orig_bailout, &EG(bailout), sizeof(jmp_buf));
+ if (setjmp(EG(bailout))!=0) {
+ /* one of the shutdown functions bailed out */
+ memcpy(&EG(bailout), &orig_bailout, sizeof(jmp_buf));
+ return;
+ }
zend_hash_apply(BG(user_shutdown_function_names),
(apply_func_t)user_shutdown_function_call);
+ memcpy(&EG(bailout), &orig_bailout, sizeof(jmp_buf));
zend_hash_destroy(BG(user_shutdown_function_names));
efree(BG(user_shutdown_function_names));
}
diff --git a/main/main.c b/main/main.c
index ab769466cd..1a1743c867 100644
--- a/main/main.c
+++ b/main/main.c
@@ -625,7 +625,6 @@ int php_request_startup(CLS_D ELS_DC PLS_DC SLS_DC)
/* initialize global variables */
PG(header_is_being_sent) = 0;
- PG(already_in_shutdown) = 0;
zend_activate(CLS_C ELS_CC);
sapi_activate(SLS_C);
@@ -664,10 +663,7 @@ void php_request_shutdown(void *dummy)
sapi_send_headers();
php_end_ob_buffering(SG(request_info).headers_only?0:1);
- if (!PG(already_in_shutdown)) {
- PG(already_in_shutdown) = 1;
- php_call_shutdown_functions();
- }
+ php_call_shutdown_functions();
php_ini_rshutdown();
diff --git a/main/php_globals.h b/main/php_globals.h
index 441ecec0d3..b6e086ced3 100644
--- a/main/php_globals.h
+++ b/main/php_globals.h
@@ -97,7 +97,6 @@ struct _php_core_globals {
long max_execution_time;
unsigned char header_is_being_sent;
- zend_bool already_in_shutdown;
};