From 9fca2a141b1fbba7822a25eab5010c55cb231eff Mon Sep 17 00:00:00 2001 From: David Schweikert Date: Thu, 10 Oct 2013 21:58:13 +0200 Subject: [PATCH] Fix wrong min RTT value with -Q option (reported by Alexander Ivanov, #51) --- ChangeLog | 1 + src/fping.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index f2f30b1..bbacf76 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ UNRELEASED * Minimum ping data size is now 0 * Removed setsockopt IPV6_CHECKSUM, which shouldn't be set and breaks compiling on Solaris (reported by Juergen Arndt) + * Fix wrong min RTT value with -Q option (reported by Alexander Ivanov, #51) 2013-05-22 David Schweikert * Version 3.5 diff --git a/src/fping.c b/src/fping.c index 5a4e1a6..bd9b60a 100644 --- a/src/fping.c +++ b/src/fping.c @@ -278,7 +278,7 @@ struct in6_addr src_addr; /* global stats */ long max_reply = 0; -long min_reply = 1000000; +long min_reply = 0; int total_replies = 0; double sum_replies = 0; int max_hostname_len = 0; @@ -1723,12 +1723,12 @@ int wait_for_reply(long wait_time) #endif /* DEBUG || _DEBUG */ this_reply = timeval_diff( ¤t_time, sent_time ); - if( this_reply > max_reply ) max_reply = this_reply; - if( this_reply < min_reply ) min_reply = this_reply; - if( this_reply > h->max_reply ) h->max_reply = this_reply; - if( this_reply < h->min_reply ) h->min_reply = this_reply; - if( this_reply > h->max_reply_i ) h->max_reply_i = this_reply; - if( this_reply < h->min_reply_i ) h->min_reply_i = this_reply; + if( !max_reply || this_reply > max_reply ) max_reply = this_reply; + if( !min_reply || this_reply < min_reply ) min_reply = this_reply; + if( !h->max_reply || this_reply > h->max_reply ) h->max_reply = this_reply; + if( !h->min_reply || this_reply < h->min_reply ) h->min_reply = this_reply; + if( !h->max_reply_i || this_reply > h->max_reply_i ) h->max_reply_i = this_reply; + if( !h->min_reply_i || this_reply < h->min_reply_i ) h->min_reply_i = this_reply; sum_replies += this_reply; h->total_time += this_reply; h->total_time_i += this_reply; @@ -2299,7 +2299,7 @@ void add_addr( char *name, char *host, FPING_SOCKADDR *ipaddr ) #endif p->timeout = timeout; p->running = 1; - p->min_reply = 10000000; + p->min_reply = 0; if( strlen( p->host ) > max_hostname_len ) max_hostname_len = strlen( p->host );