mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 01:16:31 +00:00
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.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user