Skip to content

Commit

Permalink
arping: Optimize loop checking
Browse files Browse the repository at this point in the history
4db1de6 introduced regression for -A and -U, which behave like -c1
(.i.e. sending only single packet). Fixing it to compare also count
(as it was done in 67e070d before the rewrite).

But it keeps 1 sec delay due poll() for -c > 1 (more than a single
packet), e.g. 67e070d is not fixed.

Also, ctl->unsolicited does not change, therefore it's enough be checked
only once (before while loop).

Fixes: 4db1de6 ("arping: Fix 1s delay on exit for unsolicited arpings")
Reported-by: David Bond <dbond@suse.com>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
  • Loading branch information
pevik committed May 25, 2024
1 parent 4db1de6 commit e8eb1ce
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion arping.c
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,10 @@ static int event_loop(struct run_state *ctl)
pfds[POLLFD_SOCKET].events = POLLIN | POLLERR | POLLHUP;
send_pack(ctl);

while (!(exit_loop || ctl->unsolicited)) {
if ((ctl->sent == ctl->count) && ctl->unsolicited)
goto exit;

while (!exit_loop) {
int ret;
size_t i;

Expand Down Expand Up @@ -840,6 +843,7 @@ static int event_loop(struct run_state *ctl)
}
}
}
exit:
close(sfd);
close(tfd);
freeifaddrs(ctl->ifa0);
Expand Down

0 comments on commit e8eb1ce

Please sign in to comment.