cvs: /php4 main.c php_globals.h /php4/ext/standard basic_functions.c

From: Date: Sun, 13 Feb 2000 00:27:24 +0000
Subject: cvs: /php4 main.c php_globals.h /php4/ext/standard basic_functions.c
Groups: php.version4 
Request: Send a blank email to php-version4+get-10197@lists.php.net to get a copy of this message
zeev Sat Feb 12 16:27:24 2000 EDT Modified files: /php4 main.c php_globals.h /php4/ext/standard basic_functions.c Log: Trap bailout of shutdown functions Index: php4/main.c diff -u php4/main.c:1.204 php4/main.c:1.205 --- php4/main.c:1.204 Fri Feb 11 13:14:42 2000 +++ php4/main.c Sat Feb 12 16:26:53 2000 @@ -19,7 +19,7 @@ */ -/* $Id: main.c,v 1.204 2000/02/11 21:14:42 andrei Exp $ */ +/* $Id: main.c,v 1.205 2000/02/13 00:26:53 zeev Exp $ */ #include <stdio.h> @@ -625,7 +625,6 @@ /* 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 @@ 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(); Index: php4/php_globals.h diff -u php4/php_globals.h:1.39 php4/php_globals.h:1.40 --- php4/php_globals.h:1.39 Fri Feb 11 13:14:42 2000 +++ php4/php_globals.h Sat Feb 12 16:26:53 2000 @@ -97,7 +97,6 @@ long max_execution_time; unsigned char header_is_being_sent; - zend_bool already_in_shutdown; }; Index: php4/ext/standard/basic_functions.c diff -u php4/ext/standard/basic_functions.c:1.160 php4/ext/standard/basic_functions.c:1.161 --- php4/ext/standard/basic_functions.c:1.160 Fri Feb 11 13:14:42 2000 +++ php4/ext/standard/basic_functions.c Sat Feb 12 16:26:54 2000 @@ -1053,6 +1053,7 @@ efree(shutdown_function_entry->arguments); } + int user_shutdown_function_call(php_shutdown_function_entry *shutdown_function_entry) { zval retval; @@ -1060,19 +1061,31 @@ 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)); }

« previous php.version4 (#10197) next »