]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix bug 1902 - Adds Numeric Hit and invalid request counters to IP Cache
authoramosjeffries <>
Fri, 17 Aug 2007 11:01:43 +0000 (11:01 +0000)
committeramosjeffries <>
Fri, 17 Aug 2007 11:01:43 +0000 (11:01 +0000)
src/ipcache.cc

index f3d5dfc8cc5b2060b0f23575d5ae97707ae2b5fe..817de6c9ee493fb5147f1f875de6de71e95c1396 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ipcache.cc,v 1.261 2007/05/29 13:31:40 amosjeffries Exp $
+ * $Id: ipcache.cc,v 1.262 2007/08/17 05:01:43 amosjeffries Exp $
  *
  * DEBUG: section 14    IP Cache
  * AUTHOR: Harvest Derived
@@ -77,8 +77,9 @@ static struct
     int hits;
     int misses;
     int negative_hits;
+    int numeric_hits;
+    int invalid;
 }
-
 IpcacheStats;
 
 static dlink_list lru_list;
@@ -505,6 +506,7 @@ ipcache_nbgethostbyname(const char *name, IPH * handler, void *handlerData)
 
     if (name == NULL || name[0] == '\0') {
         debugs(14, 4, "ipcache_nbgethostbyname: Invalid name!");
+        IpcacheStats.invalid++;
         dns_error_message = "Invalid hostname";
         handler(NULL, handlerData);
         return;
@@ -512,6 +514,7 @@ ipcache_nbgethostbyname(const char *name, IPH * handler, void *handlerData)
 
     if ((addrs = ipcacheCheckNumeric(name))) {
         dns_error_message = NULL;
+        IpcacheStats.numeric_hits++;
         handler(addrs, handlerData);
         return;
     }
@@ -626,8 +629,10 @@ ipcache_gethostbyname(const char *name, int flags)
 
     dns_error_message = NULL;
 
-    if ((addrs = ipcacheCheckNumeric(name)))
+    if ((addrs = ipcacheCheckNumeric(name))) {
+        IpcacheStats.numeric_hits++;
         return addrs;
+    }
 
     IpcacheStats.misses++;
 
@@ -665,16 +670,20 @@ stat_ipcache_get(StoreEntry * sentry)
     dlink_node *m;
     assert(ip_table != NULL);
     storeAppendPrintf(sentry, "IP Cache Statistics:\n");
-    storeAppendPrintf(sentry, "IPcache Entries: %d\n",
+    storeAppendPrintf(sentry, "IPcache Entries:  %d\n",
                       memInUse(MEM_IPCACHE_ENTRY));
     storeAppendPrintf(sentry, "IPcache Requests: %d\n",
                       IpcacheStats.requests);
-    storeAppendPrintf(sentry, "IPcache Hits: %d\n",
+    storeAppendPrintf(sentry, "IPcache Hits:            %d\n",
                       IpcacheStats.hits);
-    storeAppendPrintf(sentry, "IPcache Negative Hits: %d\n",
+    storeAppendPrintf(sentry, "IPcache Negative Hits:       %d\n",
                       IpcacheStats.negative_hits);
-    storeAppendPrintf(sentry, "IPcache Misses: %d\n",
+    storeAppendPrintf(sentry, "IPcache Numeric Hits:        %d\n",
+                      IpcacheStats.numeric_hits);
+    storeAppendPrintf(sentry, "IPcache Misses:          %d\n",
                       IpcacheStats.misses);
+    storeAppendPrintf(sentry, "IPcache Invalid Request: %d\n",
+                      IpcacheStats.invalid);
     storeAppendPrintf(sentry, "\n\n");
     storeAppendPrintf(sentry, "IP Cache Contents:\n\n");
     storeAppendPrintf(sentry, " %-29.29s %3s %6s %6s %1s\n",