@@ -990,26 +990,29 @@ static bool scope_try_to_dispose(zend_async_scope_t *scope)
990990{
991991 async_scope_t * async_scope = (async_scope_t * ) scope ;
992992
993- if (ZEND_ASYNC_SCOPE_IS_DISPOSED (scope )) {
993+ if (ZEND_ASYNC_SCOPE_IS_DISPOSING (scope )) {
994994 return true;
995995 }
996996
997997 if (false == SCOPE_CAN_BE_DISPOSED (async_scope )) {
998998 return false;
999999 }
10001000
1001- ZEND_ASYNC_SCOPE_SET_DISPOSED (scope );
1001+ ZEND_ASYNC_SCOPE_SET_DISPOSING (scope );
10021002
10031003 // Dispose all child scopes
10041004 for (uint32_t i = 0 ; i < async_scope -> scope .scopes .length ; ++ i ) {
10051005 async_scope_t * child_scope = (async_scope_t * ) async_scope -> scope .scopes .data [i ];
10061006 child_scope -> scope .event .dispose (& child_scope -> scope .event );
10071007 if (UNEXPECTED (EG (exception ))) {
1008+ ZEND_ASYNC_SCOPE_CLR_DISPOSING (scope );
10081009 // If an exception occurs during child scope disposal, we stop further processing
10091010 return false;
10101011 }
10111012 }
10121013
1014+ ZEND_ASYNC_SCOPE_CLR_DISPOSING (scope );
1015+
10131016 // Dispose the scope
10141017 async_scope -> scope .event .dispose (& async_scope -> scope .event );
10151018 return true;
@@ -1532,12 +1535,6 @@ static zend_always_inline bool try_to_handle_exception(
15321535
15331536static void async_scope_call_finally_handlers_dtor (finally_handlers_context_t * context )
15341537{
1535- zend_async_scope_t * scope = context -> target ;
1536- if (ZEND_ASYNC_EVENT_REF (& scope -> event ) > 0 ) {
1537- ZEND_ASYNC_EVENT_DEL_REF (& scope -> event );
1538- }
1539-
1540- scope -> try_to_dispose (scope );
15411538 context -> target = NULL ;
15421539}
15431540
@@ -1566,7 +1563,6 @@ static bool async_scope_call_finally_handlers(async_scope_t *scope)
15661563 zend_array_destroy (finally_handlers );
15671564 return false;
15681565 } else {
1569- ZEND_ASYNC_EVENT_ADD_REF (& scope -> scope .event );
15701566 return true;
15711567 }
15721568}
0 commit comments