forked from lx/netapp
Add dump of sending queue
This commit is contained in:
parent
81b2ff3a4e
commit
700f783956
1 changed files with 11 additions and 0 deletions
11
src/proto.rs
11
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 {
|
||||
|
|
Loading…
Reference in a new issue