]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Add details to username_cache display page
authorAmos Jeffries <squid3@treenet.co.nz>
Sun, 25 Apr 2010 12:44:10 +0000 (00:44 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 25 Apr 2010 12:44:10 +0000 (00:44 +1200)
* 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.

src/auth/User.cc
src/auth/User.h

index c388dc1b2b740f21602733772722fb5d6658047e..528d7b5cbc36bc3bdf32ae123326bf2ea2c6f976 100644 (file)
@@ -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<int32_t>(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<int32_t>(auth_user->expiretime - squid_curtime + Config.authenticateTTL),
                           auth_user->username()
                           );
     }
index 2e0c5d43b5eb3120e459fb24a6362c5e81a343ee..6bd2a44d860e080149e61e83b8a8353c4f8491ab 100644 (file)
@@ -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