diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2021-06-11 03:53:56 +0200 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2021-06-11 03:54:54 +0200 |
| commit | eacce69426ee17a6c04c9141a2c3658db09a7c9d (patch) | |
| tree | 0aa732c67a2086faa8832e603b9c22b558b0fbe8 /mumd/src/network | |
| parent | 311b7ad09afa0cd967b239de410708eec20e8123 (diff) | |
| download | mum-eacce69426ee17a6c04c9141a2c3658db09a7c9d.tar.gz | |
only log pings if amount of not good packets changed
Diffstat (limited to 'mumd/src/network')
| -rw-r--r-- | mumd/src/network/tcp.rs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/mumd/src/network/tcp.rs b/mumd/src/network/tcp.rs index 4140f2a..4a753bf 100644 --- a/mumd/src/network/tcp.rs +++ b/mumd/src/network/tcp.rs @@ -310,6 +310,10 @@ async fn listen( let mut crypt_state = None; let mut crypt_state_sender = Some(crypt_state_sender); + let mut last_late = 0; + let mut last_lost = 0; + let mut last_resync = 0; + loop { let packet = match stream.next().await { Some(Ok(packet)) => packet, @@ -438,6 +442,40 @@ async fn listen( } } } + ControlPacket::Ping(msg) => { + trace!("Received Ping {:?}", *msg); + + let late = msg.get_late(); + let lost = msg.get_lost(); + let resync = msg.get_resync(); + + let late = late - last_late; + let lost = lost - last_lost; + let resync = resync - last_resync; + + last_late += late; + last_lost += lost; + last_resync += resync; + + macro_rules! format_if_nonzero { + ($value:expr) => { + if $value != 0 { + format!("\n {}: {}", stringify!($value), $value) + } else { + String::new() + } + } + } + + if late != 0 || lost != 0 || resync != 0 { + debug!( + "Ping:{}{}{}", + format_if_nonzero!(late), + format_if_nonzero!(lost), + format_if_nonzero!(resync), + ); + } + } packet => { debug!("Received unhandled ControlPacket {:#?}", packet); } |
