if sending several pings in parallel, delay them in scheduler
[pingcheck] / src / host / pingscheduler.h
index 34ee755..54392c3 100644 (file)
@@ -36,7 +36,7 @@ on this file might be covered by the GNU General Public License.
 #include "host/pingprotocol.h"
 #include "dns/resolverbase.h"
 
-typedef std::list<PingerItem> pinger_list;
+typedef std::vector<PingerItem> pinger_vec;
 
 //-----------------------------------------------------------------------------
 // PingScheduler
@@ -88,6 +88,9 @@ private:
     void update_dns_resolver( PingProtocol current_protocol );
 
     void ping_when_ready();
+    void delayed_ping( const boost::system::error_code &error,
+                       const boost::asio::ip::address &ip,
+                       const int pinger_index );
     void dns_resolve_callback(const bool was_success,
                               const int recursion_count);
     void start_resolving_ping_address();
@@ -126,13 +129,15 @@ private:
     /// The Dns resolver
     ResolverItem Resolver;
     /// vector of pingers
-    pinger_list Pingers;
+    pinger_vec Pingers;
     /// number of pingers that work in parallel
     int NPingers;
     /// number of results from pingers
     int NPingersDone;
     /// delay (in ms) between pings to same IP
     int ParallelPingDelay;
+    /// timers for delayed pings
+    boost::asio::deadline_timer DelayedPingTimer;
     /// a flag whether we should ping as soon as dns is ready
     bool WantToPing;
     /// Prefix to log messages for quicker analysis/debugging