Skip to content

Commit

Permalink
Merge branch 'main' into batch-blob-api-2
Browse files Browse the repository at this point in the history
# Conflicts:
#	iroh/src/client/blobs.rs
#	iroh/src/client/tags.rs
#	iroh/src/node/rpc.rs
#	iroh/src/rpc_protocol.rs
  • Loading branch information
rklaehn committed Jun 6, 2024
2 parents f6a8d15 + b2f0b0e commit 2d04cf2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
26 changes: 18 additions & 8 deletions iroh-net/src/magicsock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,12 +531,20 @@ 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`.
//
// If we returned `Poll::Pending`, the waker driving the `poll_send` will never get woken up.
//
// Our best bet here is to log an error and return `Poll::Ready(Ok(n))`.
//
// `n` is the number of consecutive transmits in this batch that are meant for the same destination (a destination that we have no addresses for, and so we can never actually send).
//
// When we return `Poll::Ready(Ok(n))`, we are effectively dropping those n messages, by lying to QUIC and saying they were sent.
// (If we returned `Poll::Ready(Ok(0))` instead, QUIC would loop to attempt to re-send those messages, blocking other traffic.)
//
// When `QUIC` gets no `ACK`s for those messages, the connection will eventually timeout.
error!(node = %public_key.fmt_short(), "failed to send: no UDP or relay addr");
return Poll::Ready(Ok(n));
}

if (udp_addr.is_none() || udp_pending) && (relay_url.is_none() || relay_pending) {
Expand All @@ -549,14 +557,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
9 changes: 4 additions & 5 deletions iroh/src/client/blobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use crate::rpc_protocol::{
SetTagOption,
};

use super::{flatten, Iroh};
use super::{flatten, tags, Iroh};
mod batch;
pub use batch::{AddDirOpts, AddFileOpts, AddReaderOpts, Batch};

Expand Down Expand Up @@ -413,8 +413,8 @@ where
Ok(ticket)
}

fn tags_client(&self) -> crate::client::tags::Client<C> {
crate::client::tags::Client {
fn tags_client(&self) -> tags::Client<C> {
tags::Client {
rpc: self.rpc.clone(),
}
}
Expand All @@ -425,8 +425,7 @@ where
C: ServiceConnection<RpcService>,
{
async fn load(&self, hash: Hash) -> anyhow::Result<Bytes> {
let mut reader = self.read(hash).await?;
Ok(reader.read_to_bytes().await?)
self.read_to_bytes(hash).await
}
}

Expand Down
2 changes: 1 addition & 1 deletion iroh/src/rpc_protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ pub struct BlobExportRequest {
/// This should be an absolute path valid for the file system on which
/// the node runs.
pub path: PathBuf,
/// Set to [`ExportFormat::Collection`] if the `hash` refers to a [`Collection`] and you want
/// Set to [`ExportFormat::Collection`] if the `hash` refers to a collection and you want
/// to export all children of the collection into individual files.
pub format: ExportFormat,
/// The mode of exporting.
Expand Down

0 comments on commit 2d04cf2

Please sign in to comment.