diff options
author | Adam <Adam@anope.org> | 2010-09-14 18:24:14 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2010-09-14 18:24:14 -0400 |
commit | e7ac33fd622ae6e21bc9af684832b7de5cfa0c0c (patch) | |
tree | 1a9f5208bf3109db46b3b73c0030bcaba4039523 /src/dns.cpp | |
parent | 630f3815ce5e1eac9dd8f82601c955131c3dce68 (diff) |
Cleanup DNS requests when modules are unloaded, fixes unloading m_dnsbl during the middle of queries
Diffstat (limited to 'src/dns.cpp')
-rw-r--r-- | src/dns.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/dns.cpp b/src/dns.cpp index 329c03c86..7b96cf660 100644 --- a/src/dns.cpp +++ b/src/dns.cpp @@ -7,7 +7,7 @@ static inline unsigned short GetRandomID() return random(); } -DNSRequest::DNSRequest(const Anope::string &addr, QueryType qt, bool cache) : address(addr), QT(qt) +DNSRequest::DNSRequest(const Anope::string &addr, QueryType qt, bool cache, Module *c) : address(addr), QT(qt), creator(c) { if (!DNSEngine) DNSEngine = new DNSManager(); @@ -531,6 +531,22 @@ void DNSManager::Tick(time_t now) } } +void DNSManager::Cleanup(Module *mod) +{ + for (std::map<short, DNSRequest *>::iterator it = this->requests.begin(), it_end = this->requests.end(); it != it_end;) + { + short id = it->first; + DNSRequest *req = it->second; + ++it; + + if (req->creator && req->creator == mod) + { + delete req; + this->requests.erase(id); + } + } +} + DNSRequestTimeout::DNSRequestTimeout(DNSRequest *r, time_t timeout) : Timer(timeout), request(r) { this->done = false; |