summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Efremov <sem@altlinux.org>2019-03-27 02:05:14 +0300
committerSami Kerola <kerolasa@iki.fi>2019-03-31 13:15:14 +0100
commit13c24bce3c651481f539ace9b678b6accac94e96 (patch)
tree7bf1eaab9011f29566f87a4ba38a8270538cbed3
parentf06ca70849886d997406193a3c1d90850ed419ae (diff)
downloadiputils-13c24bce3c651481f539ace9b678b6accac94e96.tar.gz
arping: fix packets count
Values of the CLOCK_MONOTONIC and CLOCK_MONOTONIC_RAW are not the same and can differ, but timerfd_create() supports CLOCK_MONOTONIC only. As a solution just don't bother to set absolute value on the timer's clock and let the initial expiration time be relative to the current. This fixes commit 4df68046c86f343494fa285e949270d3a84be54d "arping: use monotonic raw clock when measuring reply times".
-rw-r--r--arping.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/arping.c b/arping.c
index 0b0a0ff..f42d7d6 100644
--- a/arping.c
+++ b/arping.c
@@ -689,10 +689,11 @@ static int event_loop(struct run_state *ctl)
struct signalfd_siginfo sigval;
int tfd;
- struct timespec now = { 0 };
struct itimerspec timerfd_vals = {
.it_interval.tv_sec = ctl->interval,
- .it_interval.tv_nsec = 0
+ .it_interval.tv_nsec = 0,
+ .it_value.tv_sec = ctl->interval,
+ .it_value.tv_nsec = 0
};
uint64_t exp, total_expires = 1;
@@ -723,13 +724,7 @@ static int event_loop(struct run_state *ctl)
error(0, errno, "timerfd_create failed");
return 1;
}
- if (clock_gettime(CLOCK_MONOTONIC_RAW, &now) == -1) {
- error(0, errno, "clock_gettime failed");
- return 1;
- }
- timerfd_vals.it_value.tv_sec = now.tv_sec + ctl->interval;
- timerfd_vals.it_value.tv_nsec = now.tv_nsec;
- if (timerfd_settime(tfd, TFD_TIMER_ABSTIME, &timerfd_vals, NULL)) {
+ if (timerfd_settime(tfd, 0, &timerfd_vals, NULL)) {
error(0, errno, "timerfd_settime failed");
return 1;
}