]> granicus.if.org Git - pdns/commitdiff
rec: Move doStats out of houseKeeping()
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 15 May 2018 08:30:32 +0000 (10:30 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 15 May 2018 13:23:32 +0000 (15:23 +0200)
(cherry picked from commit 5b05b92fde73d19f8b1c5edffa359b6065f96fd2)

pdns/pdns_recursor.cc

index 6a88bdeb64a2839a60a0f348fd34fb8a22b6e911..f40a0e26a5b31f352837ce6b10a1b7d24c16f3eb 100644 (file)
@@ -2146,7 +2146,7 @@ static void doStats(void)
 
 static void houseKeeping(void *)
 {
-  static thread_local time_t last_stat, last_rootupdate, last_prune, last_secpoll;
+  static thread_local time_t last_rootupdate, last_prune, last_secpoll;
   static thread_local int cleanCounter=0;
   static thread_local bool s_running;  // houseKeeping can get suspended in secpoll, and be restarted, which makes us do duplicate work
   try {
@@ -2178,13 +2178,7 @@ static void houseKeeping(void *)
         last_rootupdate=now.tv_sec;
     }
 
-    if (t_id == s_handlerThreadID) {
-      if(g_statisticsInterval > 0 && now.tv_sec - last_stat >= g_statisticsInterval) {
-       doStats();
-       last_stat=time(0);
-      }
-    }
-    else if(t_id == s_distributorThreadID) {
+    if(t_id == s_distributorThreadID) {
 
       if(now.tv_sec - last_secpoll >= 3600) {
        try {
@@ -3279,6 +3273,7 @@ try
 
   bool listenOnTCP(true);
 
+  time_t last_stat = 0;
   time_t last_carbon=0;
   time_t carbonInterval=::arg().asNum("carbon-interval");
   counter.store(0); // used to periodically execute certain tasks
@@ -3303,15 +3298,18 @@ try
 
     counter++;
 
-    if(!worker && statsWanted) {
-      doStats();
-    }
+    if(!worker) {
+      if(statsWanted || (g_statisticsInterval > 0 && (g_now.tv_sec - last_stat) >= g_statisticsInterval)) {
+        doStats();
+        last_stat = g_now.tv_sec;
+      }
 
-    Utility::gettimeofday(&g_now, 0);
+      Utility::gettimeofday(&g_now, 0);
 
-    if(!worker && (g_now.tv_sec - last_carbon >= carbonInterval)) {
-      MT->makeThread(doCarbonDump, 0);
-      last_carbon = g_now.tv_sec;
+      if((g_now.tv_sec - last_carbon) >= carbonInterval) {
+        MT->makeThread(doCarbonDump, 0);
+        last_carbon = g_now.tv_sec;
+      }
     }
 
     t_fdm->run(&g_now);