From: Pieter Lexis Date: Wed, 26 Oct 2016 17:32:23 +0000 (+0200) Subject: Don't exit dnsdist on an exception in maintenance X-Git-Tag: dnsdist-1.1.0-beta2~53^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F4640%2Fhead;p=thirdparty%2Fpdns.git Don't exit dnsdist on an exception in maintenance This change logs every minute if the maintenance function throws an exception. --- 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++;