Skip to content

Commit

Permalink
raise error if writable() timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
herr-seppia committed Oct 2, 2024
1 parent e1fc37e commit 0b6e7db
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/transport/sockets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 0b6e7db

Please sign in to comment.