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:
+17
-1
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user