diff options
author | Alex Auvolat <alex@adnab.me> | 2022-08-31 15:08:51 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-08-31 15:08:51 +0200 |
commit | 700f783956697ef9d5aff4d904167f50367409e9 (patch) | |
tree | abe6fd4e032d4922343fb5dcc34bf14be30fdd69 /src/proto.rs | |
parent | 81b2ff3a4e853ece8a5f2537007f386a9c7f971d (diff) | |
download | netapp-700f783956697ef9d5aff4d904167f50367409e9.tar.gz netapp-700f783956697ef9d5aff4d904167f50367409e9.zip |
Add dump of sending queue
Diffstat (limited to 'src/proto.rs')
-rw-r--r-- | src/proto.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/proto.rs b/src/proto.rs index e843bff..56afede 100644 --- a/src/proto.rs +++ b/src/proto.rs @@ -1,5 +1,6 @@ use std::collections::{HashMap, VecDeque}; use std::sync::Arc; +use std::fmt::Write; use log::trace; @@ -94,6 +95,15 @@ impl SendQueue { fn is_empty(&self) -> bool { self.items.iter().all(|(_k, v)| v.is_empty()) } + fn dump(&self) -> String { + let mut ret = String::new(); + for (prio, q) in self.items.iter() { + for item in q.iter() { + write!(&mut ret, " [{} {} ({})]", prio, item.data.len() - item.cursor, item.id).unwrap(); + } + } + ret + } } /// The SendLoop trait, which is implemented both by the client and the server @@ -117,6 +127,7 @@ pub(crate) trait SendLoop: Sync { let mut sending = SendQueue::new(); let mut should_exit = false; while !should_exit || !sending.is_empty() { + trace!("send_loop: queue = {}", sending.dump()); if let Ok((id, prio, data)) = msg_recv.try_recv() { trace!("send_loop: got {}, {} bytes", id, data.len()); sending.push(SendQueueItem { |