Fix: consider the network interface from each host.
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Wed, 14 Mar 2012 23:08:29 +0000 (20:08 -0300)
committerGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Wed, 14 Mar 2012 23:11:05 +0000 (20:11 -0300)
- 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.

src/config/option/hostportoption.cpp
src/main.cpp

index 867e65f..43557c4 100644 (file)
@@ -79,7 +79,7 @@ bool HostPortOption::parse(
             host_item->set_port( static_cast<uint16_t>(host_port) );
             ++hosts_list_iterator;
 
-            GlobalLogger.info() <<  get_command_string() << "=" << host_port << endl;
+            GlobalLogger.info() << get_command_string() << "=" << host_port << endl;
         }
 
         parsed_success = true;
index a29e3b3..0a850b1 100644 (file)
@@ -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,