From bc2c1b4f869d3e3b90c187ebb07b3c23c14ca880 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 20 Dec 2020 11:16:32 +0100 Subject: ping: fix -wN to not think that one packet is always lost Signed-off-by: Denys Vlasenko --- networking/ping.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/networking/ping.c b/networking/ping.c index bbf9f0db1..ea4fa364b 100644 --- a/networking/ping.c +++ b/networking/ping.c @@ -471,17 +471,16 @@ static void sendping_tail(void (*sp)(int), int size_pkt) { int sz; - CLR((uint16_t)G.ntransmitted % MAX_DUP_CHK); - G.ntransmitted++; - - size_pkt += datalen; - if (G.deadline_us) { unsigned n = G.cur_us - G.deadline_us; if ((int)n >= 0) print_stats_and_exit(0); } + CLR((uint16_t)G.ntransmitted % MAX_DUP_CHK); + G.ntransmitted++; + size_pkt += datalen; + /* sizeof(pingaddr) can be larger than real sa size, but I think * it doesn't matter */ sz = xsendto(pingsock, G.snd_packet, size_pkt, &pingaddr.sa, sizeof(pingaddr)); -- cgit v1.2.3