@@ -1044,7 +1044,9 @@ void async_scheduler_coroutine_enqueue(zend_coroutine_t *coroutine)
10441044 coroutine -> waker -> status = ZEND_ASYNC_WAKER_QUEUED ;
10451045
10461046 // Add to resumed_coroutines queue for event cleanup
1047- circular_buffer_push_ptr_with_resize (& ASYNC_G (resumed_coroutines ), coroutine );
1047+ if (ZEND_ASYNC_IS_SCHEDULER_CONTEXT ) {
1048+ circular_buffer_push_ptr_with_resize (& ASYNC_G (resumed_coroutines ), coroutine );
1049+ }
10481050 }
10491051
10501052 //
@@ -1074,11 +1076,11 @@ static zend_always_inline void scheduler_next_tick(void)
10741076
10751077 if (UNEXPECTED (current_time - ASYNC_G (last_reactor_tick ) > REACTOR_CHECK_INTERVAL )) {
10761078 ASYNC_G (last_reactor_tick ) = current_time ;
1077- const circular_buffer_t * queue = & ASYNC_G (coroutine_queue );
1079+ const circular_buffer_t * queue = & ASYNC_G (coroutine_queue );
10781080
10791081 has_handles = ZEND_ASYNC_REACTOR_EXECUTE (circular_buffer_is_not_empty (queue ));
10801082
1081- if (circular_buffer_is_not_empty (& ASYNC_G (resumed_coroutines ))) {
1083+ if (circular_buffer_is_not_empty (& ASYNC_G (coroutine_queue ))) {
10821084 process_resumed_coroutines ();
10831085 }
10841086
@@ -1290,7 +1292,7 @@ ZEND_STACK_ALIGNED void fiber_entry(zend_fiber_transfer *transfer)
12901292 switch_status status = COROUTINE_NOT_EXISTS ;
12911293
12921294 const circular_buffer_t * coroutine_queue = & ASYNC_G (coroutine_queue );
1293- const circular_buffer_t * resumed_coroutines = & ASYNC_G (resumed_coroutines );
1295+ circular_buffer_t * resumed_coroutines = & ASYNC_G (resumed_coroutines );
12941296
12951297 do {
12961298
@@ -1303,6 +1305,8 @@ ZEND_STACK_ALIGNED void fiber_entry(zend_fiber_transfer *transfer)
13031305 execute_microtasks ();
13041306 TRY_HANDLE_EXCEPTION ();
13051307
1308+ ZEND_ASSERT (circular_buffer_is_not_empty (resumed_coroutines ) == 0 && "resumed_coroutines should be 0" );
1309+
13061310 has_next_coroutine = circular_buffer_count (coroutine_queue ) > 0 ;
13071311 has_handles = ZEND_ASYNC_REACTOR_EXECUTE (has_next_coroutine );
13081312
0 commit comments