1
0
mirror of https://github.com/anope/anope.git synced 2026-07-03 11:33:12 +02:00

Cleanup DNS requests when modules are unloaded, fixes unloading m_dnsbl during the middle of queries

This commit is contained in:
Adam
2010-09-14 18:24:14 -04:00
parent 630f3815ce
commit e7ac33fd62
5 changed files with 28 additions and 15 deletions
+17 -1
View File
@@ -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;