From 80363c942680d06fc4c99bd2706c9c988b05c011 Mon Sep 17 00:00:00 2001 From: Guilherme Maciel Ferreira Date: Sun, 11 Mar 2012 17:26:03 -0300 Subject: [PATCH] Revert "Perform N pings using one protocol, then after those N pings, switch to" This reverts commit 46531881f06af5666d62a74836b1101cdcb779d9. --- src/host/pingerfactory.cpp | 6 +----- src/host/pingerfactory.h | 1 - src/host/pingrotate.cpp | 17 +++-------------- src/host/pingrotate.h | 11 +++-------- src/host/pingscheduler.cpp | 3 --- src/host/pingscheduler.h | 1 - src/main.cpp | 2 -- 7 files changed, 7 insertions(+), 34 deletions(-) diff --git a/src/host/pingerfactory.cpp b/src/host/pingerfactory.cpp index cc50336..561d170 100644 --- a/src/host/pingerfactory.cpp +++ b/src/host/pingerfactory.cpp @@ -116,7 +116,6 @@ PingerItem PingerFactory::createPinger( * @brief Create a Pinger object suitable to the given list of protocols. * * @param protocol_list A list of the available ping protocols. - * @param protocol_fallback_count The amount of pings to perform before change the protocol. * @param io_serv The @c io_service object. * @param network_interface The network interface name from where the ping * packet will be sent. @@ -128,13 +127,11 @@ PingerItem PingerFactory::createPinger( */ PingRotateItem PingerFactory::createPinger( const PingProtocolList &protocol_list, - const int protocol_fallback_count, io_service &io_serv, const string &network_interface, const string &destination_address, const uint16_t destination_port, const string &nameserver - ) { BOOST_ASSERT( 0 < protocol_list.size() ); @@ -149,7 +146,6 @@ PingRotateItem PingerFactory::createPinger( destination_address, destination_port, nameserver, - protocol_list, - protocol_fallback_count + protocol_list ) ); } diff --git a/src/host/pingerfactory.h b/src/host/pingerfactory.h index 8f2b71d..05d3415 100644 --- a/src/host/pingerfactory.h +++ b/src/host/pingerfactory.h @@ -45,7 +45,6 @@ public: static PingRotateItem createPinger( const PingProtocolList &protocol_list, - const int protocol_fallback_count, boost::asio::io_service &io_serv, const std::string &network_interface, const std::string &destination_address, diff --git a/src/host/pingrotate.cpp b/src/host/pingrotate.cpp index 2c94783..c8b3433 100644 --- a/src/host/pingrotate.cpp +++ b/src/host/pingrotate.cpp @@ -46,7 +46,6 @@ using boost::shared_ptr; * @param nameserver Server to resolve the addresses. * @param protocol_list A list of protocols to be used to ping the * host. The protocols will be used in the order they are in the list. - * @param protocol_fallback_count The amount of pings to perform before change the protocol. */ PingRotate::PingRotate( io_service &io_serv, @@ -54,8 +53,7 @@ PingRotate::PingRotate( const string &destination_address, const uint16_t destination_port, const string &nameserver, - const PingProtocolList protocol_list, - const int protocol_fallback_count + const PingProtocolList protocol_list ) : IoService( io_serv ), NetworkInterfaceName( network_interface ), @@ -64,8 +62,6 @@ PingRotate::PingRotate( DestinationPort( destination_port ), Nameserver( nameserver ), ProtocolList( protocol_list ), - ProtocolFallbackCount( protocol_fallback_count ), - PingCount( 0 ), Ping(), PingDoneCallback() { @@ -75,7 +71,7 @@ PingRotate::PingRotate( BOOST_ASSERT( !nameserver.empty() ); BOOST_ASSERT( 0 < protocol_list.size() ); - get_next_ping_protocol(); + update_ping_protocol(); } /** @@ -95,7 +91,6 @@ PingRotate::~PingRotate() void PingRotate::ping( function ping_done_callback ) { BOOST_ASSERT( ( 0 < DestinationPort ) && ( DestinationPort < numeric_limits::max() ) ); - BOOST_ASSERT( ( 0 <= PingCount ) && ( PingCount < numeric_limits::max() ) ); set_ping_done_callback( ping_done_callback ); @@ -108,8 +103,6 @@ void PingRotate::ping( function ping_done_callback ) DestinationPort, boost::bind(&PingRotate::ping_done_handler, this, _1) ); - - PingCount++; } bool PingRotate::resolve_ping_address() @@ -161,13 +154,9 @@ void PingRotate::get_next_ping_protocol() bool PingRotate::can_change_ping_protocol() const { - BOOST_ASSERT( ( 0 <= ProtocolFallbackCount ) && ( ProtocolFallbackCount < numeric_limits::max() ) ); - BOOST_ASSERT( ( 0 <= PingCount ) && ( PingCount < numeric_limits::max() ) ); - // TODO can_change_ping_protocol() and get_next_ping_protocol() may be implemented in a Algorithm // class that can be exchanged in this class to provide an algorithm neutral class - - return ( PingCount >= ProtocolFallbackCount ); + return true; } void PingRotate::update_dns_resolver( PingProtocol current_protocol ) diff --git a/src/host/pingrotate.h b/src/host/pingrotate.h index 61b0f3c..f666d11 100644 --- a/src/host/pingrotate.h +++ b/src/host/pingrotate.h @@ -18,8 +18,8 @@ on this file might be covered by the GNU General Public License. */ -#ifndef PING_ROTATE_H -#define PING_ROTATE_H +#ifndef PIN_GROTATE_H +#define PIN_GROTATE_H #include @@ -51,8 +51,7 @@ public: const std::string &destination_address, const uint16_t destination_port, const std::string &nameserver, - const PingProtocolList protocol_list, - const int protocol_fallback_count + const PingProtocolList protocol_list ); virtual ~PingRotate(); @@ -94,10 +93,6 @@ private: std::string Nameserver; /// The list of protocols to ping PingProtocolList ProtocolList; - /// The amount of pings to perform before change the protocol - const int ProtocolFallbackCount; - /// The amount of pings performed - int PingCount; /// Internal boost pinger object PingerItem Ping; /// The callback function diff --git a/src/host/pingscheduler.cpp b/src/host/pingscheduler.cpp index ea0b128..6138afa 100644 --- a/src/host/pingscheduler.cpp +++ b/src/host/pingscheduler.cpp @@ -53,7 +53,6 @@ using I2n::Logger::GlobalLogger; * @param destination_address The remote address to ping. * @param destination_port The remote port to ping. * @param ping_protocol_list A list of protocols to use. - * @param ping_protocol_fallback_count The amount of pings to perform before change the protocol. * @param ping_interval_in_sec Amount of time between each ping. * @param ping_fail_percentage_limit Maximum amount of pings that can fail. * @param nameserver Server to resolve the addresses. @@ -64,7 +63,6 @@ PingScheduler::PingScheduler( const string &destination_address, const uint16_t destination_port, const PingProtocolList ping_protocol_list, - const int protocol_fallback_count, const long ping_interval_in_sec, const int ping_fail_percentage_limit, const string &nameserver, @@ -89,7 +87,6 @@ PingScheduler::PingScheduler( Ping = PingerFactory::createPinger( ping_protocol_list, - protocol_fallback_count, IoService, network_interface, destination_address, diff --git a/src/host/pingscheduler.h b/src/host/pingscheduler.h index 0029297..583ff44 100644 --- a/src/host/pingscheduler.h +++ b/src/host/pingscheduler.h @@ -53,7 +53,6 @@ public: const std::string &destination_address, const uint16_t destination_port, const PingProtocolList ping_protocol_list, - const int protocol_fallback_count, const long ping_interval_in_sec, const int ping_fail_percentage_limit, const std::string &nameserver, diff --git a/src/main.cpp b/src/main.cpp index 16fc853..17f685f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -123,7 +123,6 @@ void init_pingers( string destination_address = host->get_address(); uint16_t destination_port = host->get_port(); PingProtocolList protocol_list = host->get_ping_protocol_list(); - int protocol_fallback_count = host->get_ping_protocol_fallback_count(); int ping_interval_in_sec = host->get_interval_in_sec(); PingSchedulerItem scheduler( new PingScheduler( @@ -131,7 +130,6 @@ void init_pingers( destination_address, destination_port, protocol_list, - protocol_fallback_count, ping_interval_in_sec, ping_fail_limit, nameserver, -- 1.7.1