From 2df0e9048693d88bac78ebb370b3a2529e66223d Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Thu, 25 Aug 2016 17:58:30 +0200 Subject: [PATCH] core_dns Fail new requests when this module or the owner of the request is being unloaded --- src/coremods/core_dns.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/coremods/core_dns.cpp b/src/coremods/core_dns.cpp index c95d42ea3..753b41f43 100644 --- a/src/coremods/core_dns.cpp +++ b/src/coremods/core_dns.cpp @@ -338,6 +338,7 @@ class MyManager : public Manager, public Timer, public EventHandler cache_map cache; irc::sockets::sockaddrs myserver; + bool unloading; /** Maximum number of entries in cache */ @@ -402,6 +403,7 @@ class MyManager : public Manager, public Timer, public EventHandler DNS::Request* requests[MAX_REQUEST_ID+1]; MyManager(Module* c) : Manager(c), Timer(5*60, true) + , unloading(false) { for (unsigned int i = 0; i <= MAX_REQUEST_ID; ++i) requests[i] = NULL; @@ -410,6 +412,9 @@ class MyManager : public Manager, public Timer, public EventHandler ~MyManager() { + // Ensure Process() will fail for new requests + unloading = true; + for (unsigned int i = 0; i <= MAX_REQUEST_ID; ++i) { DNS::Request* request = requests[i]; @@ -426,6 +431,9 @@ class MyManager : public Manager, public Timer, public EventHandler void Process(DNS::Request* req) { + if ((unloading) || (req->creator->dying)) + throw Exception("Module is being unloaded"); + ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Processing request to lookup " + req->question.name + " of type " + ConvToStr(req->question.type) + " to " + this->myserver.addr()); /* Create an id */ -- 2.39.5