Skip to content

Commit

Permalink
fix(worker): ignore would block errors sending outbound packets
Browse files Browse the repository at this point in the history
  • Loading branch information
max-niederman committed Apr 25, 2024
1 parent d5ffef1 commit 59f08cf
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/centipede_worker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ impl<'r> Worker<'r> {
obligation.message().as_buffer(),
&obligation.link().remote.into(),
)
.or_else(ignore_would_block)
.map_err(Error::WriteSocket)?;

write_buf = obligation.fulfill();
Expand Down Expand Up @@ -228,6 +229,14 @@ const TUN_TOKEN: mio::Token = mio::Token(usize::MAX);

const PACKET_BUFFER_SIZE: usize = 65536;

fn ignore_would_block<T: Default>(e: io::Error) -> io::Result<T> {
if e.kind() == io::ErrorKind::WouldBlock {
Ok(Default::default())
} else {
Err(e)
}
}

#[derive(Debug, Error, Diagnostic)]
pub enum Error {
#[error("failed to poll for events")]
Expand Down

0 comments on commit 59f08cf

Please sign in to comment.