From 991729038b138f9467c2f5d54b8345c8b564b076 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 31 Jan 2024 01:14:33 +0100 Subject: [PATCH 1/2] fix: handle IPC unreadable socket --- crates/transport-ipc/src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/transport-ipc/src/lib.rs b/crates/transport-ipc/src/lib.rs index 1f1b24ab8c3..2fddd280b17 100644 --- a/crates/transport-ipc/src/lib.rs +++ b/crates/transport-ipc/src/lib.rs @@ -196,6 +196,14 @@ where Ok(data_len) => { debug!(%data_len, "Read data from IPC socket"); + if data_len == 0 { + // stream is no longer readable and we're also unable to decode any more + // data. This happens if the IPC socket is closed by the other end. + // so we can return `None` here. + debug!("IPC socket EOF, stream is closed"); + return Ready(None); + } + // can try decoding again *this.drained = false; } From 2bea748e38818735c9a91dc3db4f5f470660eb6f Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 31 Jan 2024 17:02:58 +0100 Subject: [PATCH 2/2] style: move 0 check to match arm --- crates/transport-ipc/src/lib.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/crates/transport-ipc/src/lib.rs b/crates/transport-ipc/src/lib.rs index 2fddd280b17..f6912d7d22d 100644 --- a/crates/transport-ipc/src/lib.rs +++ b/crates/transport-ipc/src/lib.rs @@ -193,17 +193,15 @@ where // read more data into the buffer match ready!(poll_read_buf(this.reader.as_mut(), cx, &mut this.buf)) { + Ok(0) => { + // stream is no longer readable and we're also unable to decode any more + // data. This happens if the IPC socket is closed by the other end. + // so we can return `None` here. + debug!("IPC socket EOF, stream is closed"); + return Ready(None); + } Ok(data_len) => { debug!(%data_len, "Read data from IPC socket"); - - if data_len == 0 { - // stream is no longer readable and we're also unable to decode any more - // data. This happens if the IPC socket is closed by the other end. - // so we can return `None` here. - debug!("IPC socket EOF, stream is closed"); - return Ready(None); - } - // can try decoding again *this.drained = false; }