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 {