From: Guilherme Maciel Ferreira Date: Wed, 14 Mar 2012 23:08:29 +0000 (-0300) Subject: Fix: consider the network interface from each host. X-Git-Tag: v1.4~2 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=035c2305d3279b9fbdd50725e46ed4f5abf9d81d;p=pingcheck Fix: consider the network interface from each host. - It was keeping the same network interface (from the first host) for all hosts; - Reduced the variable scope so it is assigned on every loop iteraction. --- diff --git a/src/config/option/hostportoption.cpp b/src/config/option/hostportoption.cpp index 867e65f..43557c4 100644 --- a/src/config/option/hostportoption.cpp +++ b/src/config/option/hostportoption.cpp @@ -79,7 +79,7 @@ bool HostPortOption::parse( host_item->set_port( static_cast(host_port) ); ++hosts_list_iterator; - GlobalLogger.info() << get_command_string() << "=" << host_port << endl; + GlobalLogger.info() << get_command_string() << "=" << host_port << endl; } parsed_success = true; diff --git a/src/main.cpp b/src/main.cpp index a29e3b3..0a850b1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -113,7 +113,7 @@ void init_pingers( PingSchedulerList *scheduler_list ) { - string local_interface = configuration->get_source_network_interface(); + string default_network_interface = configuration->get_source_network_interface(); string nameserver = configuration->get_nameserver(); int ping_fail_limit = configuration->get_ping_fail_limit(); @@ -122,15 +122,15 @@ void init_pingers( { string destination_address = host->get_address(); uint16_t destination_port = host->get_port(); - if ( local_interface.empty() ) - { - local_interface = host->get_source_network_interface(); - } + string host_network_interface = host->get_source_network_interface(); + string network_interface = ( default_network_interface.empty() ) ? + host_network_interface : + default_network_interface; PingProtocol protocol = host->get_ping_protocol(); int ping_interval_in_sec = host->get_interval_in_sec(); PingSchedulerItem scheduler( new PingScheduler( - local_interface, + network_interface, destination_address, destination_port, protocol,