From bad690a95580c88d0b809509b9f9d9d3546538f9 Mon Sep 17 00:00:00 2001 From: OlivierHecart Date: Fri, 18 Oct 2024 12:22:06 +0200 Subject: [PATCH 1/3] Log and ignore OS error 55 when sending multicast --- .../zenoh-link-udp/src/multicast.rs | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/io/zenoh-links/zenoh-link-udp/src/multicast.rs b/io/zenoh-links/zenoh-link-udp/src/multicast.rs index 1ab1fbb398..b1b0d4c4cf 100644 --- a/io/zenoh-links/zenoh-link-udp/src/multicast.rs +++ b/io/zenoh-links/zenoh-link-udp/src/multicast.rs @@ -81,14 +81,23 @@ impl LinkMulticastTrait for LinkMulticastUdp { } async fn write(&self, buffer: &[u8]) -> ZResult { - self.unicast_socket + match self + .unicast_socket .send_to(buffer, self.multicast_addr) .await - .map_err(|e| { - let e = zerror!("Write error on UDP link {}: {}", self, e); - tracing::trace!("{}", e); - e.into() - }) + { + Ok(size) => Ok(size), + std::io::Result::Err(e) => { + if let Some(55) = e.raw_os_error() { + // No buffer space available + tracing::trace!("{}", e); + Ok(0) + } else { + let e = zerror!("Write error on UDP link {}: {}", self, e); + Err(e.into()) + } + } + } } async fn write_all(&self, buffer: &[u8]) -> ZResult<()> { From 68abff0843c2bb4e972c05eaede0dfd233811aec Mon Sep 17 00:00:00 2001 From: OlivierHecart Date: Fri, 18 Oct 2024 12:33:10 +0200 Subject: [PATCH 2/3] Improve log --- io/zenoh-links/zenoh-link-udp/src/multicast.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/io/zenoh-links/zenoh-link-udp/src/multicast.rs b/io/zenoh-links/zenoh-link-udp/src/multicast.rs index b1b0d4c4cf..1a2f24f936 100644 --- a/io/zenoh-links/zenoh-link-udp/src/multicast.rs +++ b/io/zenoh-links/zenoh-link-udp/src/multicast.rs @@ -90,10 +90,11 @@ impl LinkMulticastTrait for LinkMulticastUdp { std::io::Result::Err(e) => { if let Some(55) = e.raw_os_error() { // No buffer space available - tracing::trace!("{}", e); + tracing::trace!("Write error on UDP link {}: {}", self, e); Ok(0) } else { let e = zerror!("Write error on UDP link {}: {}", self, e); + tracing::trace!("{}", e); Err(e.into()) } } From f560ebd584995dde14d4be59fce4cab7ddb094bc Mon Sep 17 00:00:00 2001 From: OlivierHecart Date: Fri, 18 Oct 2024 13:46:35 +0200 Subject: [PATCH 3/3] Apply platform-specific feature gate --- io/zenoh-links/zenoh-link-udp/src/multicast.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/io/zenoh-links/zenoh-link-udp/src/multicast.rs b/io/zenoh-links/zenoh-link-udp/src/multicast.rs index 1a2f24f936..f0b40efc5d 100644 --- a/io/zenoh-links/zenoh-link-udp/src/multicast.rs +++ b/io/zenoh-links/zenoh-link-udp/src/multicast.rs @@ -88,6 +88,13 @@ impl LinkMulticastTrait for LinkMulticastUdp { { Ok(size) => Ok(size), std::io::Result::Err(e) => { + #[cfg(not(target_os = "macos"))] + { + let e = zerror!("Write error on UDP link {}: {}", self, e); + tracing::trace!("{}", e); + Err(e.into()) + } + #[cfg(target_os = "macos")] if let Some(55) = e.raw_os_error() { // No buffer space available tracing::trace!("Write error on UDP link {}: {}", self, e);