void PingRotate::get_next_ping_protocol()
{
PingProtocol ping_protocol = ProtocolRotate.front();
- ProtocolRotate.pop_front();
- ProtocolRotate.push_back(ping_protocol);
+ if ( 1 <= ProtocolList.size() )
+ {
+ PingProtocol ping_protocol = ProtocolList.front();
+
+ ProtocolList.pop_front();
- Ping = PingerFactory::createPinger( ping_protocol, IoService, NetworkInterfaceName, PingReplyTimeout );
+ Ping = PingerFactory::createPinger( ping_protocol, IoService, NetworkInterfaceName, PingReplyTimeout );
- update_dns_resolver( ping_protocol );
+ update_dns_resolver( ping_protocol );
+ }
}
bool PingRotate::can_change_ping_protocol() const
/**
* @brief Start into infinite loop of calls to resolve_and_ping
- * IoService which is started here and can be stopped through stop_pinging
+ *
+ * Does not start yet but set NextPingTimer (possibly to 0), so action starts
+ * when io_service is started
*/
void PingScheduler::start_pinging()
{
+ // assume that even at re-start there is no IP known
EverHadAnyIP = false;
if ( FirstDelay > 0 )
- {
GlobalLogger.info() << "Delaying first ping by " << FirstDelay << "s";
- (void) NextPingTimer.expires_from_now( seconds( FirstDelay ) );
- NextPingTimer.async_wait( bind( &PingScheduler::resolve_and_ping, this,
- boost::asio::placeholders::error ) );
- }
else
- resolve_and_ping(boost::system::error_code());
+ GlobalLogger.info() << "Schedule ping as soon as possible";
+
+ (void) NextPingTimer.expires_from_now( seconds( FirstDelay ) );
+ NextPingTimer.async_wait( bind( &PingScheduler::resolve_and_ping, this,
+ boost::asio::placeholders::error ) );
}