Skip to content

Commit 082dcbb

Browse files
committed
Fix resumed_coroutines assertion: remove reactor tick from libuv_io_close
libuv_io_close called libuv_reactor_execute() with SCHEDULER_CONTEXT=true to process the uv_close callback. During uv_run(), other callbacks could resume coroutines which pushed to resumed_coroutines. After restoring scheduler context to false, resumed_coroutines was never drained, causing the assertion "resumed_coroutines should be 0" in fiber_entry. Fix: remove the reactor tick entirely from io_close. The uv_close callback will be processed during the next regular reactor tick in the scheduler loop.
1 parent 565c95f commit 082dcbb

1 file changed

Lines changed: 0 additions & 9 deletions

File tree

libuv_reactor.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3862,7 +3862,6 @@ static bool libuv_io_close(zend_async_io_t *io_base)
38623862
}
38633863

38643864
io->base.state |= ZEND_ASYNC_IO_CLOSED;
3865-
bool need_close_handle = false;
38663865

38673866
/* If the reactor is already shut down (e.g. bailout during memory
38683867
* exhaustion followed by executor_globals_dtor), skip libuv calls. */
@@ -3875,12 +3874,10 @@ static bool libuv_io_close(zend_async_io_t *io_base)
38753874
io->handle.stream.data = io;
38763875
ZEND_ASYNC_EVENT_ADD_REF(&io->base.event);
38773876
uv_close((uv_handle_t *) &io->handle.stream, io_close_cb);
3878-
need_close_handle = true;
38793877
} else if (io->base.type == ZEND_ASYNC_IO_TYPE_UDP) {
38803878
io->handle.udp.data = io;
38813879
ZEND_ASYNC_EVENT_ADD_REF(&io->base.event);
38823880
uv_close((uv_handle_t *) &io->handle.udp, io_close_cb);
3883-
need_close_handle = true;
38843881
}
38853882
/* FILE type: no uv handle to close. */
38863883

@@ -3896,12 +3893,6 @@ static bool libuv_io_close(zend_async_io_t *io_base)
38963893
}
38973894
io->orig_fd = -1;
38983895

3899-
if (need_close_handle && false == ZEND_ASYNC_IS_SCHEDULER_CONTEXT) {
3900-
ZEND_ASYNC_SCHEDULER_CONTEXT = true;
3901-
libuv_reactor_execute(true);
3902-
ZEND_ASYNC_SCHEDULER_CONTEXT = false;
3903-
}
3904-
39053896
return true;
39063897
}
39073898

0 commit comments

Comments
 (0)