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

From: Date: Fri, 11 Feb 2000 21:15:13 +0000
Subject: cvs: /php4 main.c php_globals.h /php4/ext/standard array.c basic_functions.c
Groups: php.version4 
Request: Send a blank email to php-version4+get-10151@lists.php.net to get a copy of this message
andrei Fri Feb 11 13:15:13 2000 EDT Modified files: /php4 main.c php_globals.h /php4/ext/standard array.c basic_functions.c Log: (request_shutdown) Prevent infinite loop on shutdown if there is an error in shutdown function. (php_array_walk) Print a warning if the walk function doesn't exist. Split shutdown function call into a separate function that's called with zend_hash_apply() instead of as destructor to keep hash consistent. This fixes bug #3419. Index: php4/main.c diff -u php4/main.c:1.203 php4/main.c:1.204 --- php4/main.c:1.203 Fri Feb 11 07:59:26 2000 +++ php4/main.c Fri Feb 11 13:14:42 2000 @@ -19,7 +19,7 @@ */ -/* $Id: main.c,v 1.203 2000/02/11 15:59:26 zeev Exp $ */ +/* $Id: main.c,v 1.204 2000/02/11 21:14:42 andrei Exp $ */ #include <stdio.h> @@ -624,7 +624,8 @@ php_output_startup(); /* initialize global variables */ - PG(header_is_being_sent)=0; + PG(header_is_being_sent) = 0; + PG(already_in_shutdown) = 0; zend_activate(CLS_C ELS_CC); sapi_activate(SLS_C); @@ -658,11 +659,15 @@ CLS_FETCH(); ELS_FETCH(); SLS_FETCH(); + PLS_FETCH(); sapi_send_headers(); php_end_ob_buffering(SG(request_info).headers_only?0:1); - php_call_shutdown_functions(); + if (!PG(already_in_shutdown)) { + PG(already_in_shutdown) = 1; + php_call_shutdown_functions(); + } php_ini_rshutdown(); Index: php4/php_globals.h diff -u php4/php_globals.h:1.38 php4/php_globals.h:1.39 --- php4/php_globals.h:1.38 Fri Jan 28 10:29:37 2000 +++ php4/php_globals.h Fri Feb 11 13:14:42 2000 @@ -97,6 +97,7 @@ long max_execution_time; unsigned char header_is_being_sent; + zend_bool already_in_shutdown; }; Index: php4/ext/standard/array.c diff -u php4/ext/standard/array.c:1.26 php4/ext/standard/array.c:1.27 --- php4/ext/standard/array.c:1.26 Fri Feb 11 07:59:28 2000 +++ php4/ext/standard/array.c Fri Feb 11 13:14:42 2000 @@ -825,12 +825,14 @@ } /* Call the userland function */ - call_user_function_ex(CG(function_table), NULL, *BG(array_walk_func_name), - &retval_ptr, userdata ? 3 : 2, args, 0); + if (call_user_function_ex(CG(function_table), NULL, *BG(array_walk_func_name), + &retval_ptr, userdata ? 3 : 2, args, 0) == SUCCESS) { - if (retval_ptr) { zval_ptr_dtor(&retval_ptr); - } + } else + php_error(E_WARNING,"Unable to call %s() - function does not exist", + (*BG(array_walk_func_name))->value.str.val); + /* Clean up the key */ if (zend_hash_get_current_key_type(target_hash) == HASH_KEY_IS_STRING) efree(key->value.str.val); Index: php4/ext/standard/basic_functions.c diff -u php4/ext/standard/basic_functions.c:1.159 php4/ext/standard/basic_functions.c:1.160 --- php4/ext/standard/basic_functions.c:1.159 Fri Feb 11 07:59:28 2000 +++ php4/ext/standard/basic_functions.c Fri Feb 11 13:14:42 2000 @@ -1045,25 +1045,34 @@ void user_shutdown_function_dtor(php_shutdown_function_entry *shutdown_function_entry) { - pval retval; int i; - CLS_FETCH(); - 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) { - pval_destructor(&retval); - } for (i=0; i<shutdown_function_entry->arg_count; i++) { zval_ptr_dtor(&shutdown_function_entry->arguments[i]); } efree(shutdown_function_entry->arguments); } +int user_shutdown_function_call(php_shutdown_function_entry *shutdown_function_entry) +{ + zval retval; + CLS_FETCH(); + + 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 + 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(); if (BG(user_shutdown_function_names)) { + zend_hash_apply(BG(user_shutdown_function_names), + (apply_func_t)user_shutdown_function_call); zend_hash_destroy(BG(user_shutdown_function_names)); efree(BG(user_shutdown_function_names)); }

« previous php.version4 (#10151) next »