Merge pull request #25144 from neovim/backport-24983-to-release-0.9

[Backport release-0.9] fix(rpc): fix race condition
This commit is contained in:
zeertzjq 2023-09-14 09:34:53 +08:00 committed by GitHub
commit d1813f73b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -207,9 +207,15 @@ Object rpc_send_call(uint64_t id, const char *method_name, Array args, ArenaMem
// Push the frame
ChannelCallFrame frame = { request_id, false, false, NIL, NULL };
kv_push(rpc->call_stack, &frame);
LOOP_PROCESS_EVENTS_UNTIL(&main_loop, channel->events, -1, frame.returned);
LOOP_PROCESS_EVENTS_UNTIL(&main_loop, channel->events, -1, frame.returned || rpc->closed);
(void)kv_pop(rpc->call_stack);
if (rpc->closed) {
api_set_error(err, kErrorTypeException, "Invalid channel: %" PRIu64, id);
channel_decref(channel);
return NIL;
}
if (frame.errored) {
if (frame.result.type == kObjectTypeString) {
api_set_error(err, kErrorTypeException, "%s",