From c8a3f5c93c0bd10c82bd4c4fb57886bd62fde0fb Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Mon, 13 Jan 2020 12:01:01 -0500 Subject: [PATCH] osx,fsevent: fix race during uv_loop_close MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The mutex also needs to protect the access to the state->loop variable, since that's owned by the child thread and will be destroyed as soon as it processes our message. Fixes: https://github.com/libuv/libuv/issues/2625 PR-URL: https://github.com/libuv/libuv/pull/2626 Reviewed-By: Ben Noordhuis Reviewed-By: Saúl Ibarra Corretgé --- src/unix/fsevents.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/unix/fsevents.c b/src/unix/fsevents.c index deeaa63d4..ec90d46a0 100644 --- a/src/unix/fsevents.c +++ b/src/unix/fsevents.c @@ -799,13 +799,14 @@ int uv__cf_loop_signal(uv_loop_t* loop, uv_mutex_lock(&loop->cf_mutex); QUEUE_INSERT_TAIL(&loop->cf_signals, &item->member); - uv_mutex_unlock(&loop->cf_mutex); state = loop->cf_state; assert(state != NULL); pCFRunLoopSourceSignal(state->signal_source); pCFRunLoopWakeUp(state->loop); + uv_mutex_unlock(&loop->cf_mutex); + return 0; }