You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#53: Add separate queue for resumed coroutines to improve event cleanup stability
The previous clean_events_for_resumed_coroutines algorithm was unstable due to
complex tracking of circular buffer changes during coroutine additions and
buffer reallocations. This commit introduces a dedicated resumed_coroutines
queue that provides a more reliable approach.
Changes:
- Add resumed_coroutines circular buffer to module globals
- Initialize resumed_coroutines queue in PHP_RINIT_FUNCTION
- Track resumed coroutines in async_scheduler_coroutine_enqueue() and async_coroutine_resume()
- Replace complex clean_events_for_resumed_coroutines() with simple process_resumed_coroutines()
- Update scheduler_next_tick() and fiber_entry() to use new queue-based approach
- Add proper cleanup in both engine_shutdown() and async_scheduler_dtor() to prevent memory leaks
Benefits:
- Eliminates race conditions from buffer reallocation tracking
- Simplifies logic by checking queue contents instead of head pointer changes
- Improves code readability and maintainability
- Fixes memory leak of 8192 bytes in circular buffer allocation
0 commit comments