]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/auth/CredentialsCache.cc
Docs: Copyright updates for 2018 (#114)
[thirdparty/squid.git] / src / auth / CredentialsCache.cc
index 214a45d0c67ee113da82872bbae657a5f5d6c941..9398b08375d51d5fc6f64683a427b34a10f57de9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2018 The Squid Software Foundation and contributors
  *
  * Squid software is distributed under GPLv2+ license and includes
  * contributions from numerous individuals and organizations.
 
 #include "squid.h"
 #include "acl/Gadgets.h"
+#include "auth/Config.h"
 #include "auth/CredentialsCache.h"
 #include "base/RunnersRegistry.h"
 #include "Debug.h"
 #include "event.h"
-#include "SquidConfig.h"
-#include "SquidTime.h"
 
 namespace Auth {
 
@@ -28,19 +27,19 @@ public:
     {}
 
     virtual ~CredentialCacheRr() {
-        debugs(29, 5, "Terminating username cache: " << name);
+        debugs(29, 5, "Terminating Auth credentials cache: " << name);
         // invalidate the CBDATA reference.
         // causes Auth::*::User::Cache() to produce nil / invalid pointer
         delete whichCache.get();
     }
 
     virtual void endingShutdown() override {
-        debugs(29, 5, "Clearing username cache: " << name);
+        debugs(29, 5, "Clearing Auth credentials cache: " << name);
         whichCache->reset();
     }
 
     virtual void syncConfig() override {
-        debugs(29, 5, "Reconfiguring username cache: " << name);
+        debugs(29, 5, "Reconfiguring Auth credentials cache: " << name);
         whichCache->doConfigChangeCleanup();
     }
 
@@ -58,7 +57,7 @@ CredentialsCache::CredentialsCache(const char *name, const char * const prettyEv
     gcScheduled_(false),
     cacheCleanupEventName(prettyEvName)
 {
-    debugs(29, 5, "initializing " << name << " username cache");
+    debugs(29, 5, "initializing " << name << " credentials cache");
     RegisterRunner(new Auth::CredentialCacheRr(name, this));
 }
 
@@ -85,7 +84,7 @@ void
 CredentialsCache::cleanup()
 {
     // cache entries with expiretime <= expirationTime are to be evicted
-    const time_t expirationTime =  current_time.tv_sec - ::Config.authenticateTTL;
+    const time_t expirationTime =  current_time.tv_sec - Auth::TheConfig.credentialsTtl;
 
     const auto end = store_.end();
     for (auto i = store_.begin(); i != end;) {
@@ -98,14 +97,15 @@ CredentialsCache::cleanup()
             ++i;
         }
     }
+    gcScheduled_ = false;
     scheduleCleanup();
 }
 
 void
-CredentialsCache::insert(Auth::User::Pointer anAuth_user)
+CredentialsCache::insert(const SBuf &userKey, Auth::User::Pointer anAuth_user)
 {
-    debugs(29, 6, "adding " << anAuth_user->userKey());
-    store_[anAuth_user->userKey()] = anAuth_user;
+    debugs(29, 6, "adding " << userKey << " (" << anAuth_user->username() << ")");
+    store_[userKey] = anAuth_user;
     scheduleCleanup();
 }
 
@@ -132,7 +132,7 @@ CredentialsCache::scheduleCleanup()
     if (!gcScheduled_ && store_.size()) {
         gcScheduled_ = true;
         eventAdd(cacheCleanupEventName, &CredentialsCache::Cleanup,
-                 this, ::Config.authenticateGCInterval, 1);
+                 this, Auth::TheConfig.garbageCollectInterval, 1);
     }
 }