ping: fix -wN to not think that one packet is always lost

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2020-12-20 11:16:32 +01:00
parent 2124c0ec97
commit bc2c1b4f86

View File

@ -471,17 +471,16 @@ static void sendping_tail(void (*sp)(int), int size_pkt)
{ {
int sz; int sz;
CLR((uint16_t)G.ntransmitted % MAX_DUP_CHK);
G.ntransmitted++;
size_pkt += datalen;
if (G.deadline_us) { if (G.deadline_us) {
unsigned n = G.cur_us - G.deadline_us; unsigned n = G.cur_us - G.deadline_us;
if ((int)n >= 0) if ((int)n >= 0)
print_stats_and_exit(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 /* sizeof(pingaddr) can be larger than real sa size, but I think
* it doesn't matter */ * it doesn't matter */
sz = xsendto(pingsock, G.snd_packet, size_pkt, &pingaddr.sa, sizeof(pingaddr)); sz = xsendto(pingsock, G.snd_packet, size_pkt, &pingaddr.sa, sizeof(pingaddr));