summaryrefslogtreecommitdiff
path: root/src/coremods/core_dns.cpp
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2016-08-25 17:58:30 +0200
committerAttila Molnar <attilamolnar@hush.com>2016-08-25 17:58:30 +0200
commit2df0e9048693d88bac78ebb370b3a2529e66223d (patch)
tree021fce90b198c4cbcbd06377969e50ec33951708 /src/coremods/core_dns.cpp
parent754f0130893bacb2b69a32c3de9ed1b3da9659cd (diff)
core_dns Fail new requests when this module or the owner of the request is being unloaded
Diffstat (limited to 'src/coremods/core_dns.cpp')
-rw-r--r--src/coremods/core_dns.cpp8
1 files changed, 8 insertions, 0 deletions
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 */