Skip to content

Commit 2a002f9

Browse files
committed
fix(quic): concat nested index paths
Signed-off-by: Roman Volosatovs <[email protected]>
1 parent ea65bbf commit 2a002f9

File tree

2 files changed

+27
-20
lines changed

2 files changed

+27
-20
lines changed

crates/transport-quic/src/lib.rs

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -484,19 +484,6 @@ pin_project! {
484484
impl wrpc_transport::Index<Self> for Outgoing {
485485
#[instrument(level = "trace", skip(self))]
486486
fn index(&self, path: &[usize]) -> anyhow::Result<Self> {
487-
ensure!(!path.is_empty());
488-
let mut header = BytesMut::with_capacity(path.len().saturating_add(5));
489-
let depth = path.len();
490-
let n = u32::try_from(depth)
491-
.map_err(|err| std::io::Error::new(std::io::ErrorKind::InvalidInput, err))?;
492-
trace!(n, "encoding path length");
493-
Leb128Encoder.encode(n, &mut header)?;
494-
for p in path {
495-
let p = u32::try_from(*p)
496-
.map_err(|err| std::io::Error::new(std::io::ErrorKind::InvalidInput, err))?;
497-
trace!(p, "encoding path element");
498-
Leb128Encoder.encode(p, &mut header)?;
499-
}
500487
match self {
501488
Self::Opening {
502489
path: base,
@@ -509,12 +496,33 @@ impl wrpc_transport::Index<Self> for Outgoing {
509496
conn,
510497
io,
511498
..
512-
} => Ok(Self::Opening {
513-
header: header.freeze(),
514-
path: Arc::from([base, path].concat()),
515-
conn: conn.clone(),
516-
io: Arc::clone(io),
517-
}),
499+
} => {
500+
ensure!(!path.is_empty());
501+
let path: Arc<[usize]> = if base.is_empty() {
502+
Arc::from(path)
503+
} else {
504+
Arc::from([base.as_ref(), path].concat())
505+
};
506+
let mut header = BytesMut::with_capacity(path.len().saturating_add(5));
507+
let depth = path.len();
508+
let n = u32::try_from(depth)
509+
.map_err(|err| std::io::Error::new(std::io::ErrorKind::InvalidInput, err))?;
510+
trace!(n, "encoding path length");
511+
Leb128Encoder.encode(n, &mut header)?;
512+
for p in path.as_ref() {
513+
let p = u32::try_from(*p).map_err(|err| {
514+
std::io::Error::new(std::io::ErrorKind::InvalidInput, err)
515+
})?;
516+
trace!(p, "encoding path element");
517+
Leb128Encoder.encode(p, &mut header)?;
518+
}
519+
Ok(Self::Opening {
520+
header: header.freeze(),
521+
path,
522+
conn: conn.clone(),
523+
io: Arc::clone(io),
524+
})
525+
}
518526
}
519527
}
520528
}

tests/rust.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,6 @@ async fn rust_bindgen_quic_sync() -> anyhow::Result<()> {
10831083
#[cfg(feature = "quic")]
10841084
#[test_log::test(tokio::test(flavor = "multi_thread"))]
10851085
#[instrument(ret)]
1086-
#[ignore] // TODO: reenable
10871086
async fn rust_bindgen_quic_async() -> anyhow::Result<()> {
10881087
use core::net::Ipv6Addr;
10891088
use core::pin::pin;

0 commit comments

Comments
 (0)