Fix IPv6 UDP TX: reset consecutive_errors after yield, pace every 16 pkts
All checks were successful
CI / test (push) Successful in 1m27s

ENOBUFS hits every send on macOS IPv6 because the interface output queue
is full. The adaptive backoff never recovered because consecutive_errors
never reset. Now reset after sleeping, and yield more frequently (every
16 packets instead of 64).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Siavash Sameni
2026-03-31 19:13:46 +04:00
parent 50c0ba528d
commit 6288fe9f25

View File

@@ -798,11 +798,14 @@ async fn udp_tx_loop(
}
}
None => {
// Unlimited: yield every 64 packets. On ENOBUFS-prone systems
// (IPv6, macOS), sleep briefly to let the kernel drain buffers.
if seq % 64 == 0 {
// "Unlimited" mode: still need minimal pacing to prevent
// macOS interface queue overflow (ENOBUFS).
// Yield every 16 packets; if errors seen, add real delay.
if seq % 16 == 0 {
if consecutive_errors > 0 {
tokio::time::sleep(Duration::from_micros(500)).await;
// Back off enough for the NIC to drain
tokio::time::sleep(Duration::from_micros(50)).await;
consecutive_errors = 0; // reset after yielding
} else {
tokio::task::yield_now().await;
}