From: Amos Jeffries Date: Sun, 25 Apr 2010 12:44:10 +0000 (+1200) Subject: Add details to username_cache display page X-Git-Tag: SQUID_3_2_0_1~167^2~23 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=af70c154bffef7b9f86a2ff3790d39751648ed5d;p=thirdparty%2Fsquid.git Add details to username_cache display page * Check TTL - time until cached credentials will be re-validated * Cache TTL - time until cached credentials will be eligable for removal. * Add: "Next garbage collection in N seconds" - time until next removal. --- diff --git a/src/auth/User.cc b/src/auth/User.cc index c388dc1b2b..528d7b5cbc 100644 --- a/src/auth/User.cc +++ b/src/auth/User.cc @@ -51,6 +51,8 @@ // This should be converted into a pooled type. Does not need to be cbdata CBDATA_TYPE(AuthUserIP); +time_t AuthUser::last_discard = 0; + AuthUser::AuthUser(AuthConfig *aConfig) : auth_type(AUTH_UNKNOWN), config(aConfig), @@ -166,6 +168,7 @@ AuthUser::cacheInit(void) proxy_auth_username_cache = hash_create((HASHCMP *) strcmp, 7921, hash_string); assert(proxy_auth_username_cache); eventAdd("User Cache Maintenance", cacheCleanup, NULL, Config.authenticateGCInterval, 1); + last_discard = squid_curtime; } } @@ -230,6 +233,7 @@ AuthUser::cacheCleanup(void *datanotused) debugs(29, 3, "AuthUser::cacheCleanup: Finished cleaning the user cache."); eventAdd("User Cache Maintenance", cacheCleanup, NULL, Config.authenticateGCInterval, 1); + last_discard = squid_curtime; } void @@ -335,7 +339,7 @@ void AuthUser::addToNameCache() { /* AuthUserHashPointer will self-register with the username cache */ - AuthUserHashPointer *notused = new AuthUserHashPointer(this); + new AuthUserHashPointer(this); } /** @@ -348,22 +352,24 @@ AuthUser::UsernameCacheStats(StoreEntry *output) /* overview of username cache */ storeAppendPrintf(output, "Cached Usernames: %d of %d\n", proxy_auth_username_cache->count, proxy_auth_username_cache->size); + storeAppendPrintf(output, "Next Garbage Collection in %d seconds.\n", static_cast(last_discard + Config.authenticateGCInterval - squid_curtime)); /* cache dump column titles */ - storeAppendPrintf(output, "Authentication cached Usernames:\n"); - storeAppendPrintf(output, "%-15s %-9s %s\n", + storeAppendPrintf(output, "\n%-15s %-9s %-9s %s\n", "Type", - "TTL", + "Check TTL", + "Cache TTL", "Username"); - storeAppendPrintf(output, "--------------- --------- ------------------------------\n"); + storeAppendPrintf(output, "--------------- --------- --------- ------------------------------\n"); hash_first(proxy_auth_username_cache); while ((usernamehash = ((AuthUserHashPointer *) hash_next(proxy_auth_username_cache)))) { AuthUser::Pointer auth_user = usernamehash->user(); - storeAppendPrintf(output, "%-15s %-9d %s\n", + storeAppendPrintf(output, "%-15s %-9d %-9d %s\n", AuthType_str[auth_user->auth_type], auth_user->ttl(), + static_cast(auth_user->expiretime - squid_curtime + Config.authenticateTTL), auth_user->username() ); } diff --git a/src/auth/User.h b/src/auth/User.h index 2e0c5d43b5..6bd2a44d86 100644 --- a/src/auth/User.h +++ b/src/auth/User.h @@ -96,7 +96,11 @@ protected: AuthUser(AuthConfig *); private: + /** + * Garbage Collection for the username cache. + */ static void cacheCleanup(void *unused); + static time_t last_discard; /// Time of last username cache garbage collection. /** * DPW 2007-05-08