]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2136] Updated not to calculate next timing based on current timestamp in every
authorNaoki Kambe <kambe@jprs.co.jp>
Mon, 23 Jul 2012 10:47:25 +0000 (19:47 +0900)
committerNaoki Kambe <kambe@jprs.co.jp>
Wed, 8 Aug 2012 12:06:28 +0000 (21:06 +0900)
polling

src/bin/stats/stats.py.in

index e5e4bdd1540160568522bbed1e56d9ca320111a3..7e72aa358ceee14601cf48f4afeceba2141a7f9f 100755 (executable)
@@ -245,9 +245,8 @@ class Stats:
             seconds"""
             # backup original timeout
             orig_timeout = self.cc_session.get_timeout()
-            # set config['poll-interval'] * 1000 (milliseconds) to
-            # timeout of cc-sesson
-            self.cc_session.set_timeout(self.get_interval()*1000)
+            # set cc-session timeout to half of a second(500ms)
+            self.cc_session.set_timeout(500)
             try:
                 answer, env = self.cc_session.group_recvmsg(nonblock)
                 self.mccs.check_command_without_recvmsg(answer, env)
@@ -260,9 +259,14 @@ class Stats:
             self.running = True
             while self.running:
                 _check_command()
-                if self.get_interval() > 0 and get_timestamp() >= self.next_polltime:
-                    # update the next polling timestamp
-                    self.next_polltime = get_timestamp() + self.get_interval()
+                now = get_timestamp()
+                if self.get_interval() > 0 and now >= self.next_polltime:
+                    intval = self.get_interval()
+                    # decide the next polling timestamp
+                    self.next_polltime += intval
+                    # adjust next time
+                    if self.next_polltime < now:
+                        self.next_polltime = now
                     self.do_polling()
         finally:
             self.mccs.send_stopping()