From 877585539b438672f30a1943cb81e632d9f9efed Mon Sep 17 00:00:00 2001 From: Christian Herdtweck Date: Tue, 26 May 2015 18:19:33 +0200 Subject: [PATCH] to avoid going down in congested line scenario, also need longer ping timeout also bugfix in HostStatus --- src/host/hoststatus.cpp | 4 ++++ src/host/pingscheduler.cpp | 14 ++++++++++++-- src/host/pingscheduler.h | 8 ++++++-- src/main.cpp | 4 +++- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/host/hoststatus.cpp b/src/host/hoststatus.cpp index 2e1db87..42e5cc7 100644 --- a/src/host/hoststatus.cpp +++ b/src/host/hoststatus.cpp @@ -227,7 +227,11 @@ void HostStatus::analyze_ping_statistics() // However, if all pings timed out even in burst mode, then we still declare // the line down if (InBurstMode && PingCongestionCount >= PingsPerformedCount) + { + GlobalLogger.notice() << log_prefix() << "All pings timed out despite " + << "using more pings per IP --> assume connection is really down"; ExceededPingFailedLimit = true; + } // notify if the amount of pings that failed exceed the limit if ( exceeded_ping_failed_limit() ) diff --git a/src/host/pingscheduler.cpp b/src/host/pingscheduler.cpp index 72b084e..b272379 100644 --- a/src/host/pingscheduler.cpp +++ b/src/host/pingscheduler.cpp @@ -44,6 +44,7 @@ using boost::posix_time::milliseconds; using boost::shared_ptr; using I2n::Logger::GlobalLogger; + //----------------------------------------------------------------------------- // PingScheduler //----------------------------------------------------------------------------- @@ -81,7 +82,8 @@ PingScheduler::PingScheduler( LinkStatusItem link_analyzer, const int first_delay, const int n_parallel_pings, - const int parallel_ping_delay + const int parallel_ping_delay, + const int ping_timeout_factor ) : IoService( io_serv ), NetworkInterfaceName( network_interface ), @@ -95,6 +97,7 @@ PingScheduler::PingScheduler( NextPingTimer( *io_serv ), TimeSentLastPing( microsec_clock::universal_time() ), PingReplyTimeout( ping_reply_timeout ), + PingReplyTimeoutOrig( ping_reply_timeout ), HostAnalyzer( destination_address, ping_fail_percentage_limit, ping_congestion_percentage_limit, ping_congestion_duration_thresh, n_parallel_pings, @@ -106,7 +109,8 @@ PingScheduler::PingScheduler( DelayedPingTimer( *io_serv ), WantToPing( false ), LogPrefix(), - ContinueOnOutdatedIps( false ) + ContinueOnOutdatedIps( false ), + PingTimeoutFactor( ping_timeout_factor ) { BOOST_ASSERT( !network_interface.empty() ); BOOST_ASSERT( !destination_address.empty() ); @@ -378,6 +382,9 @@ void PingScheduler::update_ping_interval() GlobalLogger.debug() << LogPrefix << "- Speeding up ping interval to: " << PingIntervalInSec << "s"; + PingReplyTimeout = PingReplyTimeoutOrig * PingTimeoutFactor; + GlobalLogger.debug() << LogPrefix << "- Increase ping timeout to " + << PingReplyTimeout << "s"; } else { @@ -385,6 +392,9 @@ void PingScheduler::update_ping_interval() GlobalLogger.debug() << LogPrefix << "- Stick to the original ping " << "interval: " << PingIntervalInSec << "s"; + PingReplyTimeout = PingReplyTimeoutOrig; + GlobalLogger.debug() << LogPrefix << "- Reset ping timeout to " + << PingReplyTimeout << "s"; } } diff --git a/src/host/pingscheduler.h b/src/host/pingscheduler.h index 2916058..91da6e6 100644 --- a/src/host/pingscheduler.h +++ b/src/host/pingscheduler.h @@ -65,7 +65,8 @@ public: LinkStatusItem link_analyzer, const int first_delay, const int n_parallel_pings, - const int parallel_ping_delay + const int parallel_ping_delay, + const int ping_timeout_factor ); ~PingScheduler(); @@ -129,7 +130,9 @@ private: /// Keeps track of the time when the last ping was send boost::posix_time::ptime TimeSentLastPing; /// time threshold for ping - const int PingReplyTimeout; + int PingReplyTimeout; + /// time threshold for ping -- original value + const int PingReplyTimeoutOrig; /// Object responsible to evaluate the status of the host HostStatus HostAnalyzer; /// The Dns resolver @@ -148,6 +151,7 @@ private: std::string LogPrefix; /// Flag whether DNS resolution has failed so we have to run on outdated IPs bool ContinueOnOutdatedIps; + int PingTimeoutFactor; }; //----------------------------------------------------------------------------- diff --git a/src/main.cpp b/src/main.cpp index 597b143..5ad6319 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -283,6 +283,7 @@ bool init_pingers( int parallel_ping_delay = 100; // ms int congestion_duration_thresh = 10; // seconds int congestion_percentage_thresh = 75; + int ping_timeout_factor = 3; PingSchedulerItem scheduler( new PingScheduler( @@ -299,7 +300,8 @@ bool init_pingers( status_notifier, current_delay, n_parallel_pings, - parallel_ping_delay + parallel_ping_delay, + ping_timeout_factor ) ); scheduler_list->push_back( scheduler ); -- 1.7.1