From: Amos Jeffries Date: Mon, 7 Sep 2015 15:50:38 +0000 (-0700) Subject: make cleanup an UserNameCache object method X-Git-Tag: SQUID_4_0_1~21^2~18 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2d9bd2a161f854bdf921c0eaec81e8eb97e3eb09;p=thirdparty%2Fsquid.git make cleanup an UserNameCache object method --- diff --git a/src/auth/UserNameCache.cc b/src/auth/UserNameCache.cc index cc8f8730c8..bedd64601a 100644 --- a/src/auth/UserNameCache.cc +++ b/src/auth/UserNameCache.cc @@ -46,22 +46,28 @@ UserNameCache::Cleanup(void *data) debugs(29, 5, "checkpoint"); // data is this in disguise UserNameCache *self = static_cast(data); + self->cleanup(); +} + +void +UserNameCache::cleanup() +{ // cache entries with expiretime <= expirationTime are to be evicted const time_t expirationTime = current_time.tv_sec - ::Config.authenticateTTL; - const auto end = self->store_.end(); - for (auto i = self->store_.begin(); i != end;) { + const auto end = store_.end(); + for (auto i = store_.begin(); i != end;) { debugs(29, 6, "considering " << i->first << "(expires in " << (expirationTime - i->second->expiretime) << " sec)"); if (i->second->expiretime <= expirationTime) { debugs(29, 6, "evicting " << i->first); - i = self->store_.erase(i); //erase advances i + i = store_.erase(i); //erase advances i } else { ++i; } } - eventAdd(self->cacheCleanupEventName.c_str(), &UserNameCache::Cleanup, - self, ::Config.authenticateGCInterval, 1); + eventAdd(cacheCleanupEventName.c_str(), &UserNameCache::Cleanup, + this, ::Config.authenticateGCInterval, 1); } void diff --git a/src/auth/UserNameCache.h b/src/auth/UserNameCache.h index 57e0a57e65..8cfa431c1d 100644 --- a/src/auth/UserNameCache.h +++ b/src/auth/UserNameCache.h @@ -56,6 +56,9 @@ public: */ static void Cleanup(void *); + /// cache garbage collection, removes timed-out entries + void cleanup(); + /** obtain sorted list of usernames * */