From: Francesco Chemolli Date: Fri, 4 Sep 2015 03:37:52 +0000 (+0200) Subject: Fix username cache cleanup X-Git-Tag: SQUID_4_0_1~21^2~25 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7b890bf244bf53fca5353f0e5674e3bbcfb839d1;p=thirdparty%2Fsquid.git Fix username cache cleanup --- diff --git a/src/auth/UserNameCache.cc b/src/auth/UserNameCache.cc index 5aa0677eb8..9dedcaad4b 100644 --- a/src/auth/UserNameCache.cc +++ b/src/auth/UserNameCache.cc @@ -55,20 +55,17 @@ UserNameCache::Cleanup(void *data) //XXX for some reason if evicting directly iterators are invalidated // trying to defer deletion by using a queue - std::list toDelete; const auto end = self->store_.end(); - for (auto i = self->store_.begin(); i != end; ++i) { + for (auto i = self->store_.begin(); i != end;) { debugs(29, 2, "considering " << i->first << "(expires in " << (expirationTime - i->second->expiretime) << " sec)"); if (i->second->expiretime <= expirationTime) { - debugs(29, 2, "queueing for eviction " << i->first); - toDelete.push_back(i); + debugs(29, 2, "evicting " << i->first); + i = self->store_.erase(i); //erase advances i + } else { + ++i; } } - for (auto i : toDelete) { - debugs(29, 2, "evicting " << i->first); - self->store_.erase(i); //less efficient but safer than iter - } eventAdd(self->cacheCleanupEventName.c_str(), &UserNameCache::Cleanup, self, ::Config.authenticateGCInterval, 1); }