Skip to content

Commit cf52335

Browse files
committed
* Code related to Scope has been fixed. A main_scope was added, as it always needs to be explicitly known. Macros like ZEND_ASYNC_CURRENT_SCOPE were updated.
A new macro ZEND_ASYNC_MAIN_SCOPE was added for the main Scope.
1 parent f915035 commit cf52335

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Zend/zend_async_API.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ static void ts_globals_ctor(zend_async_globals_t * globals)
117117
globals->active_coroutine_count = 0;
118118
globals->active_event_count = 0;
119119
globals->coroutine = NULL;
120+
globals->main_scope = NULL;
120121
globals->scheduler = NULL;
121122
globals->exit_exception = NULL;
122123
}

Zend/zend_async_API.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -777,8 +777,8 @@ typedef struct {
777777
unsigned int active_event_count;
778778
/* The current coroutine context. */
779779
zend_coroutine_t *coroutine;
780-
/* The current async scope. */
781-
zend_async_scope_t *scope;
780+
/* The main async scope. */
781+
zend_async_scope_t *main_scope;
782782
/* Scheduler coroutine */
783783
zend_coroutine_t *scheduler;
784784
/* Exit exception object */
@@ -813,7 +813,8 @@ END_EXTERN_C()
813813
#define ZEND_ASYNC_GRACEFUL_SHUTDOWN ZEND_ASYNC_G(graceful_shutdown)
814814
#define ZEND_ASYNC_EXIT_EXCEPTION ZEND_ASYNC_G(exit_exception)
815815
#define ZEND_ASYNC_CURRENT_COROUTINE ZEND_ASYNC_G(coroutine)
816-
#define ZEND_ASYNC_CURRENT_SCOPE ZEND_ASYNC_G(coroutine)->scope
816+
#define ZEND_ASYNC_CURRENT_SCOPE (ZEND_ASYNC_G(coroutine) ? ZEND_ASYNC_G(coroutine)->scope : NULL)
817+
#define ZEND_ASYNC_MAIN_SCOPE ZEND_ASYNC_G(main_scope)
817818
#define ZEND_ASYNC_SCHEDULER ZEND_ASYNC_G(scheduler)
818819

819820
#define ZEND_ASYNC_INCREASE_EVENT_COUNT if (ZEND_ASYNC_G(active_event_count) < UINT_MAX) { \

0 commit comments

Comments
 (0)