46 lines
1.3 KiB
Diff
46 lines
1.3 KiB
Diff
From b94cd579083660bffa0e7d3c45ea0c1a4e8adaec Mon Sep 17 00:00:00 2001
|
|
From: liuzhikang <liuzhikang3@huawei.com>
|
|
Date: Wed, 11 Mar 2020 17:52:29 +0800
|
|
Subject: [PATCH] arping -w does not take effect
|
|
|
|
---
|
|
arping.c | 11 ++++++++---
|
|
1 file changed, 8 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/arping.c b/arping.c
|
|
index a002786..36986e8 100644
|
|
--- a/arping.c
|
|
+++ b/arping.c
|
|
@@ -694,7 +694,7 @@ static int event_loop(struct run_state *ctl)
|
|
.it_value.tv_sec = ctl->timeout,
|
|
.it_value.tv_nsec = 0
|
|
};
|
|
- uint64_t exp, total_expires = 1;
|
|
+ uint64_t exp, total_expires = 0;
|
|
|
|
unsigned char packet[4096];
|
|
struct sockaddr_storage from;
|
|
@@ -781,12 +781,17 @@ static int event_loop(struct run_state *ctl)
|
|
break;
|
|
case POLLFD_TIMER:
|
|
s = read(tfd, &exp, sizeof(uint64_t));
|
|
+ total_expires++;
|
|
if (s != sizeof(uint64_t)) {
|
|
error(0, errno, "could not read timerfd");
|
|
+ if (ctl->timeout > 0 && ((total_expires * ctl->interval) > (uint64_t)ctl->timeout)) {
|
|
+ exit_loop = 1;
|
|
+ }
|
|
continue;
|
|
}
|
|
- total_expires += exp;
|
|
- if (0 < ctl->count && (uint64_t)ctl->count < total_expires) {
|
|
+ if ((ctl->count > 0 && (total_expires >= (uint64_t)ctl->count)) ||
|
|
+ (ctl->timeout > 0 && (total_expires * ctl->interval) > (uint64_t)ctl->timeout)||
|
|
+ (ctl->quit_on_reply)) {
|
|
exit_loop = 1;
|
|
continue;
|
|
}
|
|
--
|
|
2.27.0
|
|
|