From: Amos Jeffries Date: Wed, 9 Sep 2015 17:55:18 +0000 (-0700) Subject: Pass the cache key value explicitly from the callers X-Git-Tag: SQUID_4_0_1~21^2~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=97821413cbeda2e20f54d2653d11b2a81a8b4a1b;p=thirdparty%2Fsquid.git Pass the cache key value explicitly from the callers This makes the cache class more flexibly used for other types of auth credentials not based on user names. Also, replace debugs stating 'username cache' with 'credentials cache' --- diff --git a/src/auth/CredentialsCache.cc b/src/auth/CredentialsCache.cc index 214a45d0c6..969a0711d4 100644 --- a/src/auth/CredentialsCache.cc +++ b/src/auth/CredentialsCache.cc @@ -28,19 +28,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 +58,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)); } @@ -102,10 +102,10 @@ CredentialsCache::cleanup() } 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(); } diff --git a/src/auth/CredentialsCache.h b/src/auth/CredentialsCache.h index 9c91f6afc5..b310839ae7 100644 --- a/src/auth/CredentialsCache.h +++ b/src/auth/CredentialsCache.h @@ -37,8 +37,8 @@ public: /// \returns a pointer to cached credentials, or nil if none found Auth::User::Pointer lookup(const SBuf &userKey) const; - /// add an user to the cache - void insert(Auth::User::Pointer anAuth_user); + /// add an user to the cache with the provided key + void insert(const SBuf &userKey, Auth::User::Pointer anAuth_user); /// clear cache void reset() { store_.clear(); } diff --git a/src/auth/basic/User.cc b/src/auth/basic/User.cc index 4a3749a9b0..af3abbecb9 100644 --- a/src/auth/basic/User.cc +++ b/src/auth/basic/User.cc @@ -90,6 +90,6 @@ Auth::Basic::User::Cache() void Auth::Basic::User::addToNameCache() { - Cache()->insert(this); + Cache()->insert(userKey(), this); } diff --git a/src/auth/digest/User.cc b/src/auth/digest/User.cc index 9e4a430801..a9e6f53cf1 100644 --- a/src/auth/digest/User.cc +++ b/src/auth/digest/User.cc @@ -83,6 +83,6 @@ Auth::Digest::User::Cache() void Auth::Digest::User::addToNameCache() { - Cache()->insert(this); + Cache()->insert(userKey(), this); } diff --git a/src/auth/negotiate/User.cc b/src/auth/negotiate/User.cc index 56d15475f7..fa07371236 100644 --- a/src/auth/negotiate/User.cc +++ b/src/auth/negotiate/User.cc @@ -38,6 +38,6 @@ Auth::Negotiate::User::Cache() void Auth::Negotiate::User::addToNameCache() { - Cache()->insert(this); + Cache()->insert(userKey(), this); } diff --git a/src/auth/ntlm/User.cc b/src/auth/ntlm/User.cc index f613737684..d006f6243e 100644 --- a/src/auth/ntlm/User.cc +++ b/src/auth/ntlm/User.cc @@ -38,6 +38,6 @@ Auth::Ntlm::User::Cache() void Auth::Ntlm::User::addToNameCache() { - Cache()->insert(this); + Cache()->insert(userKey(), this); }