aboutsummaryrefslogtreecommitdiff
path: root/src/recv.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-07-25 15:04:52 +0200
committerAlex Auvolat <alex@adnab.me>2022-07-25 15:04:52 +0200
commit74e57016f63b6052cf6d539812859c3a46138eee (patch)
tree9e0dd9a7176d8f977b0dac55242c2870966ee90a /src/recv.rs
parent7499721a10d1d9e977024224b9d80d91ce93628b (diff)
downloadnetapp-74e57016f63b6052cf6d539812859c3a46138eee.tar.gz
netapp-74e57016f63b6052cf6d539812859c3a46138eee.zip
Add some debugging
Diffstat (limited to 'src/recv.rs')
-rw-r--r--src/recv.rs19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/recv.rs b/src/recv.rs
index e748f18..cba42cb 100644
--- a/src/recv.rs
+++ b/src/recv.rs
@@ -59,7 +59,6 @@ pub(crate) trait RecvLoop: Sync + 'static {
{
let mut streams: HashMap<RequestID, Sender> = HashMap::new();
loop {
- trace!("recv_loop: reading packet");
let mut header_id = [0u8; RequestID::BITS as usize / 8];
match read.read_exact(&mut header_id[..]).await {
Ok(_) => (),
@@ -67,22 +66,31 @@ pub(crate) trait RecvLoop: Sync + 'static {
Err(e) => return Err(e.into()),
};
let id = RequestID::from_be_bytes(header_id);
- trace!("recv_loop: got header id: {:04x}", id);
let mut header_size = [0u8; ChunkLength::BITS as usize / 8];
read.read_exact(&mut header_size[..]).await?;
let size = ChunkLength::from_be_bytes(header_size);
- trace!("recv_loop: got header size: {:04x}", size);
let has_cont = (size & CHUNK_HAS_CONTINUATION) != 0;
let is_error = (size & ERROR_MARKER) != 0;
let packet = if is_error {
+ trace!(
+ "recv_loop: got id {}, header_size {:04x}, error {}",
+ id,
+ size,
+ size & !ERROR_MARKER
+ );
Err((size & !ERROR_MARKER) as u8)
} else {
let size = size & !CHUNK_HAS_CONTINUATION;
let mut next_slice = vec![0; size as usize];
read.read_exact(&mut next_slice[..]).await?;
- trace!("recv_loop: read {} bytes", next_slice.len());
+ trace!(
+ "recv_loop: got id {}, header_size {:04x}, {} bytes",
+ id,
+ size,
+ next_slice.len()
+ );
Ok(Bytes::from(next_slice))
};
@@ -90,6 +98,7 @@ pub(crate) trait RecvLoop: Sync + 'static {
send
} else {
let (send, recv) = mpsc::channel(4);
+ trace!("recv_loop: id {} is new channel", id);
self.recv_handler(
id,
Box::pin(tokio_stream::wrappers::ReceiverStream::new(recv)),
@@ -102,8 +111,10 @@ pub(crate) trait RecvLoop: Sync + 'static {
let _ = sender.send(packet).await;
if has_cont {
+ assert!(!is_error);
streams.insert(id, sender);
} else {
+ trace!("recv_loop: close channel id {}", id);
sender.end();
}
}