From c2ccd30c97aa0c04e4ed1d75e16bb6575a593178 Mon Sep 17 00:00:00 2001 From: Herr Seppia Date: Wed, 2 Oct 2024 13:17:52 +0200 Subject: [PATCH] raise error if writable() timeout --- src/transport/sockets.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/transport/sockets.rs b/src/transport/sockets.rs index 2dd8616..44f48f9 100644 --- a/src/transport/sockets.rs +++ b/src/transport/sockets.rs @@ -11,7 +11,7 @@ use std::time::Duration; use tokio::net::UdpSocket; use tokio::runtime::Handle; use tokio::task::block_in_place; -use tokio::time::{self, Interval}; +use tokio::time::{self, timeout, Interval}; use tracing::{info, warn}; use super::encoding::Configurable; @@ -74,7 +74,17 @@ impl MultipleOutSocket { } let retry_count = self.retry_count; for i in 1..=retry_count { - self.ipv4.writable().await?; + let writable_fn = match remote_addr.is_ipv4() { + true => self.ipv4.writable(), + false => self.ipv6.writable(), + }; + match timeout(self.udp_send_retry_interval, writable_fn).await { + Ok(inner) => inner, + Err(_) => Err(io::Error::new( + io::ErrorKind::Other, + "Unable to check writable in time", + )), + }?; let res = match remote_addr.is_ipv4() { true => self.ipv4.try_send_to(data, *remote_addr), false => self.ipv6.try_send_to(data, *remote_addr),