Skip to content

Commit

Permalink
fix(quic): concat nested index paths
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
  • Loading branch information
rvolosatovs committed Oct 2, 2024
1 parent ea65bbf commit 2a002f9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 20 deletions.
46 changes: 27 additions & 19 deletions crates/transport-quic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,19 +484,6 @@ pin_project! {
impl wrpc_transport::Index<Self> for Outgoing {
#[instrument(level = "trace", skip(self))]
fn index(&self, path: &[usize]) -> anyhow::Result<Self> {
ensure!(!path.is_empty());
let mut header = BytesMut::with_capacity(path.len().saturating_add(5));
let depth = path.len();
let n = u32::try_from(depth)
.map_err(|err| std::io::Error::new(std::io::ErrorKind::InvalidInput, err))?;
trace!(n, "encoding path length");
Leb128Encoder.encode(n, &mut header)?;
for p in path {
let p = u32::try_from(*p)
.map_err(|err| std::io::Error::new(std::io::ErrorKind::InvalidInput, err))?;
trace!(p, "encoding path element");
Leb128Encoder.encode(p, &mut header)?;
}
match self {
Self::Opening {
path: base,
Expand All @@ -509,12 +496,33 @@ impl wrpc_transport::Index<Self> for Outgoing {
conn,
io,
..
} => Ok(Self::Opening {
header: header.freeze(),
path: Arc::from([base, path].concat()),
conn: conn.clone(),
io: Arc::clone(io),
}),
} => {
ensure!(!path.is_empty());
let path: Arc<[usize]> = if base.is_empty() {
Arc::from(path)
} else {
Arc::from([base.as_ref(), path].concat())
};
let mut header = BytesMut::with_capacity(path.len().saturating_add(5));
let depth = path.len();
let n = u32::try_from(depth)
.map_err(|err| std::io::Error::new(std::io::ErrorKind::InvalidInput, err))?;
trace!(n, "encoding path length");
Leb128Encoder.encode(n, &mut header)?;
for p in path.as_ref() {
let p = u32::try_from(*p).map_err(|err| {
std::io::Error::new(std::io::ErrorKind::InvalidInput, err)
})?;
trace!(p, "encoding path element");
Leb128Encoder.encode(p, &mut header)?;
}
Ok(Self::Opening {
header: header.freeze(),
path,
conn: conn.clone(),
io: Arc::clone(io),
})
}
}
}
}
Expand Down
1 change: 0 additions & 1 deletion tests/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,6 @@ async fn rust_bindgen_quic_sync() -> anyhow::Result<()> {
#[cfg(feature = "quic")]
#[test_log::test(tokio::test(flavor = "multi_thread"))]
#[instrument(ret)]
#[ignore] // TODO: reenable
async fn rust_bindgen_quic_async() -> anyhow::Result<()> {
use core::net::Ipv6Addr;
use core::pin::pin;
Expand Down

0 comments on commit 2a002f9

Please sign in to comment.