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

Fixed possible unsafe iteration when purging dns cache, and fixed the dns cache to not expire all of the records for specific hosts if the records have different TTLs

(cherry picked from commit 736df4bd98b952aad459fdf7914735e88f97c4b2)
This commit is contained in:
Adam
2010-11-11 19:24:41 -05:00
parent 0d2db1f9f9
commit 12c5314863
+4 -3
View File
@@ -557,15 +557,16 @@ void DNSManager::Tick(time_t now)
{
Log(LOG_DEBUG_2) << "Resolver: Purging DNS cache";
for (std::multimap<Anope::string, DNSRecord *>::iterator it = this->cache.begin(), it_end = this->cache.end(); it != it_end;)
for (std::multimap<Anope::string, DNSRecord *>::iterator it = this->cache.begin(), it_next; it != this->cache.end(); it = it_next)
{
Anope::string host = it->first;
DNSRecord *req = it->second;
++it;
it_next = it;
++it_next;
if (req->created + req->ttl < now)
{
this->cache.erase(host);
this->cache.erase(it);
delete req;
}
}