osx,fsevent: fix race during uv_loop_close

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 <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This commit is contained in:
Jameson Nash 2020-01-13 12:01:01 -05:00
parent c68111759d
commit c8a3f5c93c

View File

@ -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;
}