diff options
author | Sergey Slipchenko <faergeek@gmail.com> | 2023-09-09 15:40:09 +0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-09 19:40:09 +0800 |
commit | c422722b2e94b94d7f9374dbae12f17580cd1d41 (patch) | |
tree | 0b597109cea4f5e17f4b0bf2d1b9995f67361e85 | |
parent | d4e80a051e54a60eae05880c6aa89d8abde6e935 (diff) | |
download | rneovim-c422722b2e94b94d7f9374dbae12f17580cd1d41.tar.gz rneovim-c422722b2e94b94d7f9374dbae12f17580cd1d41.tar.bz2 rneovim-c422722b2e94b94d7f9374dbae12f17580cd1d41.zip |
fix(rpc): fix hang with channel closed while waiting for response
-rw-r--r-- | src/nvim/msgpack_rpc/channel.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 3a9b36a914..b753d46d64 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -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", |