aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGregory Anders <8965202+gpanders@users.noreply.github.com>2023-12-12 13:19:46 -0600
committerGitHub <noreply@github.com>2023-12-12 13:19:46 -0600
commit1907abb4c27857fe7f4e7394f32e130f9955a2e7 (patch)
treed60376bdedc8ac7537cec672ab0385c5e9ed5962 /src
parent2c96f1c4f052540ad0ca5cb6f631088aa9114f9c (diff)
downloadrneovim-1907abb4c27857fe7f4e7394f32e130f9955a2e7.tar.gz
rneovim-1907abb4c27857fe7f4e7394f32e130f9955a2e7.tar.bz2
rneovim-1907abb4c27857fe7f4e7394f32e130f9955a2e7.zip
fix(stream): do not close handle if it is already closing (#26537)
uv_close asserts that a handle is not already closing. We can guard against this assertion failure by manually checking the handle's closing status ourselves.
Diffstat (limited to 'src')
-rw-r--r--src/nvim/event/stream.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/nvim/event/stream.c b/src/nvim/event/stream.c
index 17c1b0a072..8baecbbb31 100644
--- a/src/nvim/event/stream.c
+++ b/src/nvim/event/stream.c
@@ -128,15 +128,22 @@ void stream_may_close(Stream *stream)
void stream_close_handle(Stream *stream)
FUNC_ATTR_NONNULL_ALL
{
+ uv_handle_t *handle = NULL;
if (stream->uvstream) {
if (uv_stream_get_write_queue_size(stream->uvstream) > 0) {
WLOG("closed Stream (%p) with %zu unwritten bytes",
(void *)stream,
uv_stream_get_write_queue_size(stream->uvstream));
}
- uv_close((uv_handle_t *)stream->uvstream, close_cb);
+ handle = (uv_handle_t *)stream->uvstream;
} else {
- uv_close((uv_handle_t *)&stream->uv.idle, close_cb);
+ handle = (uv_handle_t *)&stream->uv.idle;
+ }
+
+ assert(handle != NULL);
+
+ if (!uv_is_closing(handle)) {
+ uv_close(handle, close_cb);
}
}