From 5f3ea719133bb528dd2b2ea4bca875b56a8cedee Mon Sep 17 00:00:00 2001 From: Pieter Lexis Date: Wed, 26 Oct 2016 19:32:23 +0200 Subject: [PATCH] Don't exit dnsdist on an exception in maintenance This change logs every minute if the maintenance function throws an exception. --- pdns/dnsdist.cc | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index e390131516..6ea4b1a39a 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -1247,15 +1247,27 @@ void* maintThread() { int interval = 1; size_t counter = 0; + int32_t secondsToWaitLog = 0; for(;;) { sleep(interval); { std::lock_guard lock(g_luamutex); - auto f =g_lua.readVariable > >("maintenance"); - if(f) - (*f)(); + auto f = g_lua.readVariable > >("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++; -- 2.47.2