Update fping.c

Should only increase num_alive if response is not a duplicate.  

In cases where multiple pings are sent, num_alive can increase past one for a host if a duplicate ping response is received while h->num_recv ==1.
pull/151/head
brownowski 5 years ago committed by GitHub
parent 12961d59ec
commit 5883c6f272
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2149,6 +2149,27 @@ int wait_for_reply(long wait_time)
sum_replies += this_reply;
h->total_time += this_reply;
total_replies++;
if (h->num_recv == 1) {
num_alive++;
if (verbose_flag || alive_flag) {
printf("%s", h->host);
if (verbose_flag)
printf(" is alive");
if (elapsed_flag)
printf(" (%s ms)", sprint_tm(this_reply));
if (addr_cmp((struct sockaddr*)&response_addr, (struct sockaddr*)&h->saddr)) {
char buf[INET6_ADDRSTRLEN];
getnameinfo((struct sockaddr*)&response_addr, sizeof(response_addr), buf, INET6_ADDRSTRLEN, NULL, 0, NI_NUMERICHOST);
fprintf(stderr, " [<- %s]", buf);
}
printf("\n");
}
}
}
/* received ping is cool, so process it */
@ -2185,27 +2206,6 @@ int wait_for_reply(long wait_time)
}
}
if (h->num_recv == 1) {
num_alive++;
if (verbose_flag || alive_flag) {
printf("%s", h->host);
if (verbose_flag)
printf(" is alive");
if (elapsed_flag)
printf(" (%s ms)", sprint_tm(this_reply));
if (addr_cmp((struct sockaddr*)&response_addr, (struct sockaddr*)&h->saddr)) {
char buf[INET6_ADDRSTRLEN];
getnameinfo((struct sockaddr*)&response_addr, sizeof(response_addr), buf, INET6_ADDRSTRLEN, NULL, 0, NI_NUMERICHOST);
fprintf(stderr, " [<- %s]", buf);
}
printf("\n");
}
}
if (per_recv_flag) {
if (timestamp_flag) {
printf("[%lu.%06lu] ",

Loading…
Cancel
Save