Skip to content

Commit

Permalink
return Poll::Pending when we have no relay URL or direct addresses …
Browse files Browse the repository at this point in the history
…to send on
  • Loading branch information
ramfox committed May 23, 2024
1 parent c8690a2 commit 9f2e906
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions iroh-net/src/magicsock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,12 +531,10 @@ impl MagicSock {
}

if udp_addr.is_none() && relay_url.is_none() {
// Handle no addresses being available
warn!(node = %public_key.fmt_short(), "failed to send: no UDP or relay addr");
return Poll::Ready(Err(io::Error::new(
io::ErrorKind::NotConnected,
"no UDP or relay address available for node",
)));
// Returning an error here would lock up the entire `Endpoint`.
// Instead, log an error and return `Poll::Pending`, the connection will timeout.
error!(node = %public_key.fmt_short(), "failed to send: no UDP or relay addr");
return Poll::Pending;
}

if (udp_addr.is_none() || udp_pending) && (relay_url.is_none() || relay_pending) {
Expand All @@ -549,14 +547,16 @@ impl MagicSock {
}

if !relay_sent && !udp_sent && !pings_sent {
warn!(node = %public_key.fmt_short(), "failed to send: no UDP or relay addr");
// Returning an error here would lock up the entire `Endpoint`.
// Instead, log an error and return `Poll::Pending`, the connection will timeout.
let err = udp_error.unwrap_or_else(|| {
io::Error::new(
io::ErrorKind::NotConnected,
"no UDP or relay address available for node",
)
});
return Poll::Ready(Err(err));
error!(node = %public_key.fmt_short(), "{err:?}");
return Poll::Pending;
}

trace!(
Expand Down

0 comments on commit 9f2e906

Please sign in to comment.