commit c422722b2e94b94d7f9374dbae12f17580cd1d41
parent d4e80a051e54a60eae05880c6aa89d8abde6e935
Author: Sergey Slipchenko <faergeek@gmail.com>
Date: Sat, 9 Sep 2023 15:40:09 +0400
fix(rpc): fix hang with channel closed while waiting for response
Diffstat:
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git 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",