]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
make cleanup an UserNameCache object method
authorAmos Jeffries <squid3@treenet.co.nz>
Mon, 7 Sep 2015 15:50:38 +0000 (08:50 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Mon, 7 Sep 2015 15:50:38 +0000 (08:50 -0700)
src/auth/UserNameCache.cc
src/auth/UserNameCache.h

index cc8f8730c8f226145d97ce09b7d17952d9ffc0d9..bedd64601a6e74c65dc917e67a0a6d4de2fceaea 100644 (file)
@@ -46,22 +46,28 @@ UserNameCache::Cleanup(void *data)
     debugs(29, 5, "checkpoint");
     // data is this in disguise
     UserNameCache *self = static_cast<UserNameCache *>(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
index 57e0a57e65f544b6733e67adf5a66536f064ff34..8cfa431c1d0b1c8821c6c7cac733479eb972d04b 100644 (file)
@@ -56,6 +56,9 @@ public:
      */
     static void Cleanup(void *);
 
+    /// cache garbage collection, removes timed-out entries
+    void cleanup();
+
     /** obtain sorted list of usernames
      *
      */