mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-09-09 14:01:06 +03:00
fix: bound log volume on sites whose rate a peer or retry loop controls
Debug output goes to the log file, so a site that fires per received message or per retry lets someone else decide how much a machine writes to disk. The WebRTC work added the first such sites. - KCP io loop: absorbing ICMP errors as packet loss made a broken socket write ~100 lines a second for the 60s until the pong timeout reaps it. Log by run instead: one line when a run starts, one per ~5s while it persists so a stuck socket stays visible, and one on recovery with the total. - punch_udp: the recv error retries every 10ms for up to MAX_TIME, so one line per occurrence wrote thousands per punch. Log the first, report the count in the timeout message. - ICE candidate paths (client, mediator): the peer sets the candidate rate and the rendezvous route carrying them needs no prior punch, so throttle to one line a minute each with the suppressed count. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ExUfAkYbq8UC9pQCiLy8TQ
This commit is contained in:
@@ -2642,6 +2642,7 @@ pub async fn punch_udp(
|
||||
const MAX_INTERVAL: Duration = Duration::from_millis(200);
|
||||
const MAX_TIME: Duration = Duration::from_secs(20);
|
||||
let mut packets_sent = 0;
|
||||
let mut recv_errors = 0u32;
|
||||
socket.send(&[]).await.ok();
|
||||
packets_sent += 1;
|
||||
let mut last_send_time = Instant::now();
|
||||
@@ -2652,7 +2653,7 @@ pub async fn punch_udp(
|
||||
tokio::select! {
|
||||
_ = hbb_common::sleep(retry_interval.as_secs_f32()) => {
|
||||
if tm.elapsed() > MAX_TIME {
|
||||
bail!("UDP punch is timed out, stop sending packets after {:?} packets", packets_sent);
|
||||
bail!("UDP punch is timed out, stop sending packets after {packets_sent:?} packets, {recv_errors} recv errors absorbed");
|
||||
}
|
||||
let elapsed = last_send_time.elapsed();
|
||||
|
||||
@@ -2674,7 +2675,13 @@ pub async fn punch_udp(
|
||||
// is expected and surfaces as ConnectionReset/Refused on a connected
|
||||
// socket (notably 10054 on Windows). Treat it as loss and keep punching;
|
||||
// MAX_TIME above still bounds the whole attempt.
|
||||
log::debug!("UDP punch recv error (treated as loss): {e}");
|
||||
// Log only the first: this retries every 10ms for up to MAX_TIME, so one
|
||||
// line per occurrence would write thousands into the log file per punch.
|
||||
// The count is reported once at the end.
|
||||
recv_errors += 1;
|
||||
if recv_errors == 1 {
|
||||
log::debug!("UDP punch recv error (treated as loss): {e}");
|
||||
}
|
||||
hbb_common::sleep(0.01).await;
|
||||
}
|
||||
Ok(n) => {
|
||||
|
||||
Reference in New Issue
Block a user