diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-08-25 19:36:06 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-08-25 19:36:06 +0200 |
commit | 78a5ef9d2c034b5a6314fb66279160331d25cc73 (patch) | |
tree | c1aa3da54a1b5acb463982d441d13fe773a07b7d | |
parent | 375951667287b1c6007dcab8809c13e1b4fec67a (diff) | |
download | busybox-w32-78a5ef9d2c034b5a6314fb66279160331d25cc73.tar.gz busybox-w32-78a5ef9d2c034b5a6314fb66279160331d25cc73.tar.bz2 busybox-w32-78a5ef9d2c034b5a6314fb66279160331d25cc73.zip |
ping: use setitimer() instead of ualarm()
function old new delta
sendping_tail 218 265 +47
ualarm 79 - -79
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 1/0 up/down: 47/-79) Total: -32 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/ping.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/networking/ping.c b/networking/ping.c index a579ea4ae..570184fee 100644 --- a/networking/ping.c +++ b/networking/ping.c | |||
@@ -485,9 +485,15 @@ static void sendping_tail(void (*sp)(int), int size_pkt) | |||
485 | bb_error_msg_and_die(bb_msg_write_error); | 485 | bb_error_msg_and_die(bb_msg_write_error); |
486 | 486 | ||
487 | if (pingcount == 0 || G.ntransmitted < pingcount) { | 487 | if (pingcount == 0 || G.ntransmitted < pingcount) { |
488 | /* Didn't send all pings yet - schedule next in 1s */ | 488 | /* Didn't send all pings yet - schedule next in -i SEC interval */ |
489 | struct itimerval i; | ||
489 | signal(SIGALRM, sp); | 490 | signal(SIGALRM, sp); |
490 | ualarm(G.interval_us, 0); | 491 | /*ualarm(G.interval_us, 0); - does not work for >=1sec on some libc */ |
492 | i.it_interval.tv_sec = 0; | ||
493 | i.it_interval.tv_usec = 0; | ||
494 | i.it_value.tv_sec = G.interval_us / 1000000; | ||
495 | i.it_value.tv_usec = G.interval_us % 1000000; | ||
496 | setitimer(ITIMER_REAL, &i, NULL); | ||
491 | } else { /* -c NN, and all NN are sent */ | 497 | } else { /* -c NN, and all NN are sent */ |
492 | /* Wait for the last ping to come back. | 498 | /* Wait for the last ping to come back. |
493 | * -W timeout: wait for a response in seconds. | 499 | * -W timeout: wait for a response in seconds. |