From 59f08cf9b634e8d83fd4562a7fd74fdbd433386e Mon Sep 17 00:00:00 2001 From: Max Niederman Date: Wed, 24 Apr 2024 23:43:12 -0700 Subject: [PATCH] fix(worker): ignore would block errors sending outbound packets --- packages/centipede_worker/src/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/centipede_worker/src/lib.rs b/packages/centipede_worker/src/lib.rs index 86d4865..fa7a60d 100644 --- a/packages/centipede_worker/src/lib.rs +++ b/packages/centipede_worker/src/lib.rs @@ -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(); @@ -228,6 +229,14 @@ const TUN_TOKEN: mio::Token = mio::Token(usize::MAX); const PACKET_BUFFER_SIZE: usize = 65536; +fn ignore_would_block(e: io::Error) -> io::Result { + 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")]