blob: 568991c02b0a34d1bb40e50d252d811b5a298936 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001From: Sven Eckelmann <sven@narfation.org>
2Date: Fri, 22 Apr 2022 11:14:08 +0200
3Subject: batctl: ping: Skip sleep after last packet
4
5The -i option for ping is documented as interval between ping requests. But
6the sleep was also applied after all the requested pings already sent out.
7As result, the user had to wait additional time until the statistics for
8the (limited) ping test was printed.
9
10Just skip the last sleep in case there will be no next ping packet to avoid
11this problem.
12
13Reported-by: Roman Le bg <roman@romanlebg.fr>
14Signed-off-by: Sven Eckelmann <sven@narfation.org>
15Origin: upstream, https://git.open-mesh.org/batctl.git/commit/47d063213d5843d1ca33c557bd4a874db3e90e9e)
16
17--- a/ping.c
18+++ b/ping.c
19@@ -282,6 +282,10 @@ read_packet:
20 }
21
22 sleep:
23+ /* skip last sleep in case no more packets will be sent out */
24+ if (loop_count == 0)
25+ continue;
26+
27 if (loop_interval > 0)
28 sleep(loop_interval);
29 else if ((tv.tv_sec != 0) || (tv.tv_usec != 0))