* Please see the COPYING and CONTRIBUTORS files for details.
*/
+/* debug section 29 */
+
#include "squid.h"
#include "auth/UserNameCache.h"
#include "acl/Gadgets.h" //for aclCacheMatchFlush
#include "SquidConfig.h"
#include "SquidTime.h"
+// XXX: reset debugs levels to something sane
+
namespace Auth {
CBDATA_CLASS_INIT(UserNameCache);
UserNameCache::UserNameCache(const char *name) :
cachename(name), cacheCleanupEventName("User cache cleanup: ")
{
+ debugs(29, 2, "initializing " << name << " username cache");
cacheCleanupEventName.append(name);
eventAdd(cacheCleanupEventName.c_str(), &UserNameCache::Cleanup,
this, ::Config.authenticateGCInterval, 1);
Auth::User::Pointer
UserNameCache::lookup(const SBuf &userKey) const
{
+ debugs(29, 2, "lookup for " << userKey);
auto p = store_.find(userKey);
if (p == store_.end())
return User::Pointer(nullptr);
void
UserNameCache::Cleanup(void *data)
{
+ debugs(29, 2, "checkpoint");
if (!cbdataReferenceValid(data))
return;
// data is this in disguise
const time_t expirationTime = current_time.tv_sec - ::Config.authenticateTTL;
const auto end = self->store_.end();
for (auto i = self->store_.begin(); i != end; ++i) {
- if (i->second->expiretime <= expirationTime)
+ if (i->second->expiretime <= expirationTime) {
+ debugs(29, 2, "evicting " << i->first);
self->store_.erase(i);
+ }
}
}
void
UserNameCache::insert(Auth::User::Pointer anAuth_user)
{
+ debugs(29, 2, "adding " << anAuth_user->SBUserKey());
store_[anAuth_user->SBUserKey()] = anAuth_user;
}
void
UserNameCache::endingShutdown()
{
+ debugs(29, 2, "Shutting down username cache " << cachename);
eventDelete(&UserNameCache::Cleanup, this);
reset();
}
void
UserNameCache::syncConfig()
{
+ debugs(29, 2, "Reconfiguring username cache " << cachename);
for (auto i : store_) {
aclCacheMatchFlush(&i.second->proxy_match_cache); //flush
}
/* connection is authenticated */
debugs(29, 4, HERE << "authenticated user " << auth_user_request->user()->username());
+#if !NEWCACHE
/* see if this is an existing user */
AuthUserHashPointer *usernamehash = static_cast<AuthUserHashPointer *>(hash_lookup(proxy_auth_username_cache, auth_user_request->user()->userKey()));
Auth::User::Pointer local_auth_user = lm_request->user();
/* store user in hash's */
local_auth_user->addToNameCache();
}
+#else
+
+#endif
/* set these to now because this is either a new login from an
* existing user or a new user */
local_auth_user->expiretime = current_time.tv_sec;