]> granicus.if.org Git - php/commitdiff
MFH: - Execute destructors earlier
authorfoobar <sniper@php.net>
Sun, 24 Apr 2005 14:49:00 +0000 (14:49 +0000)
committerfoobar <sniper@php.net>
Sun, 24 Apr 2005 14:49:00 +0000 (14:49 +0000)
NEWS
Zend/tests/bug20240.phpt
Zend/zend.c
Zend/zend.h
Zend/zend_execute.h
Zend/zend_execute_API.c
main/main.c

diff --git a/NEWS b/NEWS
index 73f401cd0b6d278dc1d605a481f3e1c1c27c34e5..c9f698b4bf8a38518c15794c043cdbf2700b5125 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,8 @@ PHP                                                                        NEWS
 - Fixed bug #32753 (Undefined constant SQLITE_NOTADB). (Ilia)
 - Fixed bug #32699 (pg_affected_rows() was defined when it was not available).
   (Derick)
+- Fixed bug #32686 (Require/include file in destructor causes segfault).
+  (Marcus)
 - Fixed bug #32682 (ext/mssql: Error on module shutdown when called from
   activescript). (Frank)
 - Fixed bug #32647 (Using register_shutdown_function() with invalid callback
index acf673a277b7d32a77873ddd2e38df9b657cd645..43950440067af7b40eefe0af1353c28627248a3a 100755 (executable)
@@ -39,5 +39,5 @@ echo "Done\n";
 2
 3
 Done
-test::destructor
 test::__destruct
+test::destructor
index 3467b61a04035431412920dca1433c88a09e77c4..0fb5c59656e09dc9f444543f37a7f75ca34fa1f5 100644 (file)
@@ -803,6 +803,13 @@ void zend_deactivate_modules(TSRMLS_D)
        } zend_end_try();
 }
 
+void zend_call_destructors(TSRMLS_D) 
+{
+       zend_try {
+               shutdown_destructors(TSRMLS_C);
+       } zend_end_try();
+}
+
 void zend_deactivate(TSRMLS_D)
 {
        /* we're no longer executing anything */
index e70c8d1972693a9ac476cd2d5bc92e30289366be..095a8c301d034734d878629bbe48fb86cf336040 100644 (file)
@@ -452,6 +452,7 @@ END_EXTERN_C()
 
 void zend_activate(TSRMLS_D);
 void zend_deactivate(TSRMLS_D);
+void zend_call_destructors(TSRMLS_D);
 void zend_activate_modules(TSRMLS_D);
 void zend_deactivate_modules(TSRMLS_D);
 void zend_post_deactivate_modules(TSRMLS_D);
index d4d02a49e70a18017de7495dfc9c4d8e057e4392..2ff6ba25eb486eeb3ac710b7d09211bc4e4170bb 100644 (file)
@@ -49,6 +49,7 @@ ZEND_API extern void (*zend_execute_internal)(zend_execute_data *execute_data_pt
 
 void init_executor(TSRMLS_D);
 void shutdown_executor(TSRMLS_D);
+void shutdown_destructors(TSRMLS_D);
 ZEND_API void execute(zend_op_array *op_array TSRMLS_DC);
 ZEND_API void execute_internal(zend_execute_data *execute_data_ptr, int return_value_used TSRMLS_DC);
 ZEND_API int zend_is_true(zval *op);
index 3d31332b6e48fa137f535f9bc7eb32c2d9236445..ea944e08409b76741e40fb11ac8b024f934109a3 100644 (file)
@@ -185,6 +185,15 @@ void init_executor(TSRMLS_D)
        EG(This) = NULL;
 }
 
+void shutdown_destructors(TSRMLS_D) {
+       zend_try {
+               zend_objects_store_call_destructors(&EG(objects_store) TSRMLS_CC);
+       } zend_catch {
+               /* if we couldn't destruct cleanly, mark all objects as destructed anyway */
+               zend_objects_store_mark_destructed(&EG(objects_store) TSRMLS_CC);
+       } zend_end_try();
+}
+
 void shutdown_executor(TSRMLS_D)
 {
        zend_try {
@@ -204,7 +213,6 @@ void shutdown_executor(TSRMLS_D)
                }
 */
                zend_llist_apply(&zend_extensions, (llist_apply_func_t) zend_extension_deactivator TSRMLS_CC);
-               zend_objects_store_call_destructors(&EG(objects_store) TSRMLS_CC);
                zend_hash_graceful_reverse_destroy(&EG(symbol_table));
        } zend_catch {
                /* if we couldn't destruct cleanly, mark all objects as destructed anyway */
index 32f2b6883cc5182bf2ff64c819dca7b35ada6c54..9f067bd0ac5a8337356c45e9b68932bc1f55363f 100644 (file)
@@ -1193,6 +1193,10 @@ void php_request_shutdown(void *dummy)
                sapi_send_headers(TSRMLS_C);
        } zend_end_try();
 
+       zend_try {
+               zend_call_destructors(TSRMLS_C);
+       } zend_end_try();
+
        if (PG(modules_activated)) zend_try {
                php_call_shutdown_functions(TSRMLS_C);
        } zend_end_try();