b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | From: Sven Eckelmann <sven@narfation.org> |
| 2 | Date: Fri, 22 Apr 2022 11:14:08 +0200 |
| 3 | Subject: batctl: ping: Skip sleep after last packet |
| 4 | |
| 5 | The -i option for ping is documented as interval between ping requests. But |
| 6 | the sleep was also applied after all the requested pings already sent out. |
| 7 | As result, the user had to wait additional time until the statistics for |
| 8 | the (limited) ping test was printed. |
| 9 | |
| 10 | Just skip the last sleep in case there will be no next ping packet to avoid |
| 11 | this problem. |
| 12 | |
| 13 | Reported-by: Roman Le bg <roman@romanlebg.fr> |
| 14 | Signed-off-by: Sven Eckelmann <sven@narfation.org> |
| 15 | Origin: 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)) |