Skip to content

Commit

Permalink
fix: handle IPC unreadable socket
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse committed Jan 31, 2024
1 parent e6f98e1 commit 8c597ff
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion crates/transport-ipc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ extern crate tracing;
use bytes::{Buf, BytesMut};
use futures::{ready, AsyncRead, AsyncWriteExt, StreamExt};
use interprocess::local_socket::{tokio::LocalSocketStream, ToLocalSocketName};
use std::task::Poll::Ready;
use std::task::{Poll, Poll::Ready};
use tokio::select;
use tokio_util::compat::FuturesAsyncReadCompatExt;

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 8c597ff

Please # to comment.