Add dump of sending queue

This commit is contained in:
Alex 2022-08-31 15:08:51 +02:00
parent 81b2ff3a4e
commit 700f783956
Signed by untrusted user: lx
GPG key ID: 0E496D15096376BE

View file

@ -1,5 +1,6 @@
use std::collections::{HashMap, VecDeque}; use std::collections::{HashMap, VecDeque};
use std::sync::Arc; use std::sync::Arc;
use std::fmt::Write;
use log::trace; use log::trace;
@ -94,6 +95,15 @@ impl SendQueue {
fn is_empty(&self) -> bool { fn is_empty(&self) -> bool {
self.items.iter().all(|(_k, v)| v.is_empty()) 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 /// 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 sending = SendQueue::new();
let mut should_exit = false; let mut should_exit = false;
while !should_exit || !sending.is_empty() { while !should_exit || !sending.is_empty() {
trace!("send_loop: queue = {}", sending.dump());
if let Ok((id, prio, data)) = msg_recv.try_recv() { if let Ok((id, prio, data)) = msg_recv.try_recv() {
trace!("send_loop: got {}, {} bytes", id, data.len()); trace!("send_loop: got {}, {} bytes", id, data.len());
sending.push(SendQueueItem { sending.push(SendQueueItem {