From: Remi Gacogne Date: Tue, 26 Dec 2023 13:07:05 +0000 (+0100) Subject: dnsdist: Clean up the Lua objects before exiting X-Git-Tag: auth-4.9.0-alpha1~10^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F13667%2Fhead;p=thirdparty%2Fpdns.git dnsdist: Clean up the Lua objects before exiting When code coverage is enabled, we try to call `exit()` instead of our usual use of `_exit()` to get more accurate coverage. It does however trigger a race condition between the destruction of Lua objects and the Lua context(s) they belong to, so we try to explicitly clean up the objects before calling `exit()`. --- diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index 3df62e18e2..54ba9777d0 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -2525,8 +2525,8 @@ static void usage() #ifdef COVERAGE static void cleanupLuaObjects() { - /* when our coverage mode is enabled, we need to make - that the Lua objects destroyed before the Lua contexts. */ + /* when our coverage mode is enabled, we need to make sure + that the Lua objects are destroyed before the Lua contexts. */ g_ruleactions.setState({}); g_respruleactions.setState({}); g_cachehitrespruleactions.setState({}); @@ -3215,6 +3215,7 @@ int main(int argc, char** argv) errlog("Fatal pdns error: %s", ae.reason); } #ifdef COVERAGE + cleanupLuaObjects(); exit(EXIT_FAILURE); #else _exit(EXIT_FAILURE); @@ -3224,6 +3225,7 @@ int main(int argc, char** argv) { errlog("Fatal error: %s", e.what()); #ifdef COVERAGE + cleanupLuaObjects(); exit(EXIT_FAILURE); #else _exit(EXIT_FAILURE); @@ -3233,6 +3235,7 @@ int main(int argc, char** argv) { errlog("Fatal pdns error: %s", ae.reason); #ifdef COVERAGE + cleanupLuaObjects(); exit(EXIT_FAILURE); #else _exit(EXIT_FAILURE);