aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/channel.c
diff options
context:
space:
mode:
authorerw7 <erw7.github@gmail.com>2021-11-12 00:07:03 +0900
committerzeertzjq <zeertzjq@outlook.com>2022-03-12 19:23:45 +0800
commit5051510ade5f171c1239906c8638e804356186fe (patch)
tree43ce21d99a58a7c77baf6f98d0c5234070db93e4 /src/nvim/channel.c
parentab456bc304965d83585cd248284cb36c96927457 (diff)
downloadrneovim-5051510ade5f171c1239906c8638e804356186fe.tar.gz
rneovim-5051510ade5f171c1239906c8638e804356186fe.tar.bz2
rneovim-5051510ade5f171c1239906c8638e804356186fe.zip
fix(channel): fix channel consistency
- Fix the problem that chanclose() does not work for channel created by nvim_open_term(). - Fix the problem that the loopback channel is not released. - Fix the error message when sending raw data to the loopback channel.
Diffstat (limited to 'src/nvim/channel.c')
-rw-r--r--src/nvim/channel.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/nvim/channel.c b/src/nvim/channel.c
index d79c0acc4a..f87b3a2f8f 100644
--- a/src/nvim/channel.c
+++ b/src/nvim/channel.c
@@ -138,8 +138,14 @@ bool channel_close(uint64_t id, ChannelPart part, const char **error)
*error = (const char *)e_invstream;
return false;
}
- api_free_luaref(chan->stream.internal.cb);
- chan->stream.internal.cb = LUA_NOREF;
+ if (chan->term) {
+ api_free_luaref(chan->stream.internal.cb);
+ chan->stream.internal.cb = LUA_NOREF;
+ chan->stream.internal.closed = true;
+ terminal_close(chan->term, 0);
+ } else {
+ channel_decref(chan);
+ }
break;
default:
@@ -536,7 +542,11 @@ size_t channel_send(uint64_t id, char *data, size_t len, bool data_owned, const
}
if (chan->streamtype == kChannelStreamInternal) {
- if (!chan->term) {
+ if (chan->is_rpc) {
+ *error = _("Can't send raw data to rpc channel");
+ goto retfree;
+ }
+ if (!chan->term || chan->stream.internal.closed) {
*error = _("Can't send data to closed stream");
goto retfree;
}