From: Francesco Chemolli Date: Thu, 3 Sep 2015 12:04:49 +0000 (+0200) Subject: Removed cache registration on Auth::*::User ctor, implemented instead Auth::*::addToN... X-Git-Tag: SQUID_4_0_1~21^2~38 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=283c905d60221168131f5f48b6339ebcca9d6de5;p=thirdparty%2Fsquid.git Removed cache registration on Auth::*::User ctor, implemented instead Auth::*::addToNameCache in place of Auth::User::addToNameCache --- diff --git a/src/auth/User.cc b/src/auth/User.cc index a826807a24..1c6cef3c00 100644 --- a/src/auth/User.cc +++ b/src/auth/User.cc @@ -14,6 +14,7 @@ #include "auth/Config.h" #include "auth/Gadgets.h" #include "auth/User.h" +#include "auth/UserNameCache.h" #include "auth/UserRequest.h" #include "event.h" #include "globals.h" @@ -315,16 +316,6 @@ Auth::User::BuildUserKey(const char *username, const char *realm) return key; } -/** - * Add the Auth::User structure to the username cache. - */ -void -Auth::User::addToNameCache() -{ - /* AuthUserHashPointer will self-register with the username cache */ - new AuthUserHashPointer(this); -} - /** * Dump the username cache statictics for viewing... */ diff --git a/src/auth/User.h b/src/auth/User.h index 806c4db53b..e849b20db7 100644 --- a/src/auth/User.h +++ b/src/auth/User.h @@ -83,7 +83,8 @@ public: void removeIp(Ip::Address); void addIp(Ip::Address); - void addToNameCache(); + /// add the Auth::User to the protocol-specific username cache. + virtual void addToNameCache() = 0; static void UsernameCacheStats(StoreEntry * output); static CbcPointer Cache(); //must be implemented in subclasses diff --git a/src/auth/basic/User.cc b/src/auth/basic/User.cc index ff0cfb5b25..f6b8d669e6 100644 --- a/src/auth/basic/User.cc +++ b/src/auth/basic/User.cc @@ -9,6 +9,7 @@ #include "squid.h" #include "auth/basic/Config.h" #include "auth/basic/User.h" +#include "auth/Gadgets.h" // for AuthUserHashPointer #include "auth/UserNameCache.h" #include "Debug.h" #include "SquidConfig.h" @@ -20,7 +21,6 @@ Auth::Basic::User::User(Auth::Config *aConfig, const char *aRequestRealm) : queue(NULL), currentRequest(NULL) { - Cache()->insert(Pointer(this)); } Auth::Basic::User::~User() @@ -89,3 +89,10 @@ Auth::Basic::User::Cache() return p; } +void +Auth::Basic::User::addToNameCache() +{ + /* AuthUserHashPointer will self-register with the username cache */ + new AuthUserHashPointer(this); //legacy + Cache()->insert(this); +} diff --git a/src/auth/basic/User.h b/src/auth/basic/User.h index 949ff11386..ec366df485 100644 --- a/src/auth/basic/User.h +++ b/src/auth/basic/User.h @@ -38,6 +38,7 @@ public: // userKey ->Auth::User::Pointer cache static CbcPointer Cache(); + virtual void addToNameCache() override; char *passwd; diff --git a/src/auth/digest/User.cc b/src/auth/digest/User.cc index f4d1b4408d..5dd558fc6e 100644 --- a/src/auth/digest/User.cc +++ b/src/auth/digest/User.cc @@ -9,6 +9,7 @@ #include "squid.h" #include "auth/digest/Config.h" #include "auth/digest/User.h" +#include "auth/Gadgets.h" // for AuthUserHashPointer #include "auth/UserNameCache.h" #include "Debug.h" #include "dlink.h" @@ -20,7 +21,6 @@ Auth::Digest::User::User(Auth::Config *aConfig, const char *aRequestRealm) : HA1created(0) { memset(HA1, 0, sizeof(HA1)); - Cache()->insert(Pointer(this)); } Auth::Digest::User::~User() @@ -80,3 +80,11 @@ Auth::Digest::User::Cache() static CbcPointer p(new Auth::UserNameCache("digest")); return p; } + +void +Auth::Digest::User::addToNameCache() +{ + /* AuthUserHashPointer will self-register with the username cache */ + new AuthUserHashPointer(this); //legacy + Cache()->insert(this); +} diff --git a/src/auth/digest/User.h b/src/auth/digest/User.h index e1257f75c0..12edda4f60 100644 --- a/src/auth/digest/User.h +++ b/src/auth/digest/User.h @@ -29,6 +29,7 @@ public: virtual int32_t ttl() const; static CbcPointer Cache(); + virtual void addToNameCache() override; HASH HA1; int HA1created; diff --git a/src/auth/negotiate/User.cc b/src/auth/negotiate/User.cc index a72d9095cb..47bdfb6889 100644 --- a/src/auth/negotiate/User.cc +++ b/src/auth/negotiate/User.cc @@ -8,6 +8,7 @@ #include "squid.h" #include "auth/Config.h" +#include "auth/Gadgets.h" // for AuthUserHashPointer #include "auth/negotiate/User.h" #include "auth/UserNameCache.h" #include "Debug.h" @@ -15,7 +16,6 @@ Auth::Negotiate::User::User(Auth::Config *aConfig, const char *aRequestRealm) : Auth::User(aConfig, aRequestRealm) { - Cache()->insert(Pointer(this)); } Auth::Negotiate::User::~User() @@ -35,3 +35,11 @@ Auth::Negotiate::User::Cache() static CbcPointer p(new Auth::UserNameCache("negotiate")); return p; } + +void +Auth::Negotiate::User::addToNameCache() +{ + /* AuthUserHashPointer will self-register with the username cache */ + new AuthUserHashPointer(this); //legacy + Cache()->insert(this); +} diff --git a/src/auth/negotiate/User.h b/src/auth/negotiate/User.h index f63e857716..7566af1cde 100644 --- a/src/auth/negotiate/User.h +++ b/src/auth/negotiate/User.h @@ -30,6 +30,8 @@ public: virtual int32_t ttl() const; static CbcPointer Cache(); + virtual void addToNameCache() override; + dlink_list proxy_auth_list; }; diff --git a/src/auth/ntlm/User.cc b/src/auth/ntlm/User.cc index 4a3f09429d..57b23e4d44 100644 --- a/src/auth/ntlm/User.cc +++ b/src/auth/ntlm/User.cc @@ -8,6 +8,7 @@ #include "squid.h" #include "auth/Config.h" +#include "auth/Gadgets.h" // for AuthUserHashPointer #include "auth/ntlm/User.h" #include "auth/UserNameCache.h" #include "Debug.h" @@ -15,7 +16,6 @@ Auth::Ntlm::User::User(Auth::Config *aConfig, const char *aRequestRealm) : Auth::User(aConfig, aRequestRealm) { - Cache()->insert(Pointer(this)); } Auth::Ntlm::User::~User() @@ -35,3 +35,11 @@ Auth::Ntlm::User::Cache() static CbcPointer p(new Auth::UserNameCache("basic")); return p; } + +void +Auth::Ntlm::User::addToNameCache() +{ + /* AuthUserHashPointer will self-register with the username cache */ + new AuthUserHashPointer(this); //legacy + Cache()->insert(this); +} diff --git a/src/auth/ntlm/User.h b/src/auth/ntlm/User.h index 8ed6fbdd93..3e63df0ab2 100644 --- a/src/auth/ntlm/User.h +++ b/src/auth/ntlm/User.h @@ -31,6 +31,7 @@ public: virtual int32_t ttl() const; static CbcPointer Cache(); + virtual void addToNameCache() override; dlink_list proxy_auth_list; };