diff options
author | Adam <Adam@anope.org> | 2010-11-11 19:24:41 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2010-11-11 19:34:23 -0500 |
commit | 12c53148635e5a7a7c69931d0cf49a7ffb1f3e1a (patch) | |
tree | 87e6d12d77c7b181bf223e4efec4d3b74a96d3b1 | |
parent | 0d2db1f9f907616d4b83dccd34f95bf31c95ba0f (diff) |
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)
-rw-r--r-- | src/dns.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/dns.cpp b/src/dns.cpp index e587cc330..5bdd2a4eb 100644 --- a/src/dns.cpp +++ b/src/dns.cpp @@ -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; } } |