]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Don't exit dnsdist on an exception in maintenance 4640/head
authorPieter Lexis <pieter.lexis@powerdns.com>
Wed, 26 Oct 2016 17:32:23 +0000 (19:32 +0200)
committerPieter Lexis <pieter.lexis@powerdns.com>
Tue, 1 Nov 2016 11:22:55 +0000 (12:22 +0100)
This change logs every minute if the maintenance function throws an
exception.

pdns/dnsdist.cc

index e3901315161a7cbf2496d34ba83918767e895138..6ea4b1a39a4a8ff2073a3844869180d7bbccf6f3 100644 (file)
@@ -1247,15 +1247,27 @@ void* maintThread()
 {
   int interval = 1;
   size_t counter = 0;
+  int32_t secondsToWaitLog = 0;
 
   for(;;) {
     sleep(interval);
 
     {
       std::lock_guard<std::mutex> lock(g_luamutex);
-      auto f =g_lua.readVariable<boost::optional<std::function<void()> > >("maintenance");
-      if(f)
-        (*f)();
+      auto f = g_lua.readVariable<boost::optional<std::function<void()> > >("maintenance");
+      if(f) {
+        try {
+          (*f)();
+          secondsToWaitLog = 0;
+        }
+        catch(std::exception &e) {
+          if (secondsToWaitLog <= 0) {
+            infolog("Error during execution of maintenance function: %s", e.what());
+            secondsToWaitLog = 61;
+          }
+          secondsToWaitLog -= interval;
+        }
+      }
     }
 
     counter++;