win: remove bad assert in uv_loop_close

This assert was stronger than necessary (we assert the actual condition
later in this function). And it's vulnerable to a race condition
occurring in uv__work_done where we drain the work queue but still have
a stale message on this object.

Fixes: https://github.com/libuv/libuv/issues/2610
PR-URL: https://github.com/libuv/libuv/pull/2615
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Jameson Nash 2020-01-09 10:32:19 -05:00
parent 3016fbc40b
commit 623aa05ac7

View File

@ -321,8 +321,13 @@ void uv__loop_close(uv_loop_t* loop) {
uv__loops_remove(loop);
/* close the async handle without needing an extra loop iteration */
assert(!loop->wq_async.async_sent);
/* Close the async handle without needing an extra loop iteration.
* We might have a pending message, but we're just going to destroy the IOCP
* soon, so we can just discard it now without the usual risk of a getting
* another notification from GetQueuedCompletionStatusEx after calling the
* close_cb (which we also skip defining). We'll assert later that queue was
* actually empty and all reqs handled. */
loop->wq_async.async_sent = 0;
loop->wq_async.close_cb = NULL;
uv__handle_closing(&loop->wq_async);
uv__handle_close(&loop->wq_async);