]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Migrated statHistCount callers to StatHist::count
authorFrancesco Chemolli <kinkie@squid-cache.org>
Tue, 6 Dec 2011 14:24:47 +0000 (15:24 +0100)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Tue, 6 Dec 2011 14:24:47 +0000 (15:24 +0100)
16 files changed:
src/CacheDigest.cc
src/HttpHdrCc.cc
src/HttpHdrScTarget.cc
src/HttpHeader.cc
src/StatHist.cc
src/StatHist.h
src/client_side.cc
src/comm/ModDevPoll.cc
src/comm/ModEpoll.cc
src/comm/ModPoll.cc
src/comm/ModSelect.cc
src/comm/ModSelectWin32.cc
src/fqdncache.cc
src/icp_v2.cc
src/ipcache.cc
src/tests/stub_StatHist.cc

index 9f649cd5f2b2fd19253bfbacb03952abb7a82471..ac26bde4f8942c2ec545f05d52e36c34150a736b 100644 (file)
@@ -177,7 +177,7 @@ cacheDigestAdd(CacheDigest * cd, const cache_key * key)
             on_xition_cnt++;
         }
 
-        statHistCount(&statCounter.cd.on_xition_count, on_xition_cnt);
+        statCounter.cd.on_xition_count.count(on_xition_cnt);
     }
 #endif
     cd->count++;
index a913c9dc5100a154a4f21ebae103d02512df2777..1939ad66ad68ee518a0266bc6e2724dffac2727c 100644 (file)
@@ -286,7 +286,7 @@ httpHdrCcUpdateStats(const HttpHdrCc * cc, StatHist * hist)
 
     for (c = CC_PUBLIC; c < CC_ENUM_END; ++c)
         if (cc->isSet(c))
-            statHistCount(hist, c);
+            hist->count(c);
 }
 
 void
index 1639ccb76ee38fa75aa5e457da70d4f74be4ebb3..aac03689ace6cdb73f8afc3f906b30071cb8bb0d 100644 (file)
@@ -72,5 +72,5 @@ HttpHdrScTarget::updateStats(StatHist * hist) const
 
     for (c = SC_NO_STORE; c < SC_ENUM_END; ++c)
         if (isSet(c))
-            statHistCount(hist, c);
+            hist->count(c);
 }
index ab9cdc44f1fb184547ea7ef8074dca57fcc5cc41..ca2e71a93259746461254af01a0ff270aad0f68e 100644 (file)
@@ -441,7 +441,7 @@ HttpHeader::clean()
 
     if (owner <= hoReply) {
         if (0 != entries.count)
-            statHistCount(&HttpHeaderStats[owner].hdrUCountDistr, entries.count);
+            HttpHeaderStats[owner].hdrUCountDistr.count(entries.count);
 
         HttpHeaderStats[owner].destroyedCount++;
 
@@ -453,7 +453,7 @@ HttpHeader::clean()
             if (e->id < 0 || e->id >= HDR_ENUM_END) {
                 debugs(55, 0, "HttpHeader::clean BUG: entry[" << pos << "] is invalid (" << e->id << "). Ignored.");
             } else {
-                statHistCount(&HttpHeaderStats[owner].fieldTypeDistr, e->id);
+                HttpHeaderStats[owner].fieldTypeDistr.count(e->id);
                 /* yes, this deletion leaves us in an inconsistent state */
                 delete e;
             }
index e9f8c8fef634367c61a1943fad7f5051370c60b3..e3b4b779af5fe7891e40a5565dab0ec301497481 100644 (file)
@@ -108,28 +108,13 @@ StatHist::operator =(const StatHist & src)
     return *this;
 }
 
-/*
- * same as statHistCopy but will do nothing if capacities do not match; the
- * latter happens, for example, when #peers changes during reconfiguration;
- * if it happens too often we should think about more general solution..
- */
-void
-statHistSafeCopy(StatHist * Dest, const StatHist * Orig)
-{
-    assert(Dest && Orig);
-    assert(Dest->bins);
-
-    if (Dest->capacity == Orig->capacity)
-        *Dest=*Orig;
-}
-
 void
-statHistCount(StatHist * H, double val)
+StatHist::count(double val)
 {
-    const int bin = statHistBin(H, val);
-    assert(H->bins);           /* make sure it got initialized */
-    assert(0 <= bin && bin < H->capacity);
-    H->bins[bin]++;
+    const int bin = statHistBin(this, val);
+    assert(bins);              /* make sure it got initialized */
+    assert(0 <= bin && bin < capacity);
+    ++bins[bin];
 }
 
 static int
index e853d4255684f2d8fdcfb000bbd6f23a6492d6b6..729980740349afb07856f95ff14973115bd9f557 100644 (file)
@@ -50,7 +50,7 @@ public:
     hbase_f *val_out;       /* e.g., exp() for log based histogram */
     double deltaPctile(const StatHist &B, double pctile) const;
     double val(int bin) const; //todo: make private
-    void count(double val) const;
+    void count(double val);
     StatHist &operator=(const StatHist &);
     StatHist() : bins(NULL), capacity(0), min(0), max(0), scale(1.0),
             val_in(NULL), val_out(NULL) {};
@@ -66,8 +66,6 @@ private:
 
 /* StatHist */
 SQUIDCEXTERN void statHistCount(StatHist * H, double val);
-SQUIDCEXTERN void statHistCopy(StatHist * Dest, const StatHist * Orig);
-SQUIDCEXTERN void statHistSafeCopy(StatHist * Dest, const StatHist * Orig);
 SQUIDCEXTERN double statHistDeltaMedian(const StatHist * A, const StatHist * B);
 SQUIDCEXTERN double statHistDeltaPctile(const StatHist * A, const StatHist * B, double pctile);
 SQUIDCEXTERN void statHistDump(const StatHist * H, StoreEntry * sentry, StatHistBinDumper * bd);
index e4fe53206197fe277f9466d8cbe059a0501d03e6..069bbeb66fdad14818f14f1d01e6e9df600f1515 100644 (file)
@@ -440,7 +440,7 @@ clientUpdateStatCounters(log_type logType)
 void
 clientUpdateStatHistCounters(log_type logType, int svc_time)
 {
-    statHistCount(&statCounter.client_http.all_svc_time, svc_time);
+    statCounter.client_http.all_svc_time.count(svc_time);
     /**
      * The idea here is not to be complete, but to get service times
      * for only well-defined types.  For example, we don't include
@@ -451,11 +451,11 @@ clientUpdateStatHistCounters(log_type logType, int svc_time)
     switch (logType) {
 
     case LOG_TCP_REFRESH_UNMODIFIED:
-        statHistCount(&statCounter.client_http.nh_svc_time, svc_time);
+        statCounter.client_http.nh_svc_time.count(svc_time);
         break;
 
     case LOG_TCP_IMS_HIT:
-        statHistCount(&statCounter.client_http.nm_svc_time, svc_time);
+        statCounter.client_http.nm_svc_time.count(svc_time);
         break;
 
     case LOG_TCP_HIT:
@@ -463,13 +463,13 @@ clientUpdateStatHistCounters(log_type logType, int svc_time)
     case LOG_TCP_MEM_HIT:
 
     case LOG_TCP_OFFLINE_HIT:
-        statHistCount(&statCounter.client_http.hit_svc_time, svc_time);
+        statCounter.client_http.hit_svc_time.count(svc_time);
         break;
 
     case LOG_TCP_MISS:
 
     case LOG_TCP_CLIENT_REFRESH_MISS:
-        statHistCount(&statCounter.client_http.miss_svc_time, svc_time);
+        statCounter.client_http.miss_svc_time.count(svc_time);
         break;
 
     default:
@@ -513,8 +513,7 @@ clientUpdateHierCounters(HierarchyLogEntry * someEntry)
         i = &someEntry->ping;
 
         if (clientPingHasFinished(i))
-            statHistCount(&statCounter.icp.query_svc_time,
-                          tvSubUsec(i->start, i->stop));
+            statCounter.icp.query_svc_time.count(tvSubUsec(i->start, i->stop));
 
         if (i->timeout)
             statCounter.icp.query_timeouts++;
index 5c790ec2066efe7a3d31327e7a927708ef651ab7..ab39bb00def5fa1d1c2467003100d5efe4c3c6ed 100644 (file)
@@ -378,7 +378,7 @@ Comm::DoSelect(int msec)
     PROF_stop(comm_check_incoming);
     getCurrentTime();
 
-    statHistCount(&statCounter.select_fds_hist, num);
+    statCounter.select_fds_hist.count(num);
 
     if (num == 0)
         return COMM_TIMEOUT; /* no error */
index 51e6a86e806e7b43ffeb467cf29d7579b3407e19..f0e01d8612c9cec53c5862028c3c0d61f33549ed 100644 (file)
@@ -275,7 +275,7 @@ Comm::DoSelect(int msec)
     PROF_stop(comm_check_incoming);
     getCurrentTime();
 
-    statHistCount(&statCounter.select_fds_hist, num);
+    statCounter.select_fds_hist.count(num);
 
     if (num == 0)
         return COMM_TIMEOUT;           /* No error.. */
index ecc950ea8460e8ee9a9dbdc607c884ab6b10d261..8004d33eae9bb63c1803c4933e07ec072ab63eb9 100644 (file)
@@ -306,7 +306,7 @@ comm_poll_icp_incoming(void)
     if (nevents > INCOMING_ICP_MAX)
         nevents = INCOMING_ICP_MAX;
 
-    statHistCount(&statCounter.comm_icp_incoming, nevents);
+    statCounter.comm_icp_incoming.count(nevents);
 }
 
 static void
@@ -340,7 +340,7 @@ comm_poll_http_incoming(void)
     if (nevents > INCOMING_HTTP_MAX)
         nevents = INCOMING_HTTP_MAX;
 
-    statHistCount(&statCounter.comm_http_incoming, nevents);
+    statCounter.comm_http_incoming.count(nevents);
 }
 
 /* poll all sockets; call handlers for those that are ready. */
@@ -450,7 +450,7 @@ Comm::DoSelect(int msec)
         getCurrentTime();
 
         debugs(5, num ? 5 : 8, "comm_poll: " << num << "+" << npending << " FDs ready");
-        statHistCount(&statCounter.select_fds_hist, num);
+        statCounter.select_fds_hist.count(num);
 
         if (num == 0 && npending == 0)
             continue;
@@ -621,7 +621,7 @@ comm_poll_dns_incoming(void)
     if (nevents > INCOMING_DNS_MAX)
         nevents = INCOMING_DNS_MAX;
 
-    statHistCount(&statCounter.comm_dns_incoming, nevents);
+    statCounter.comm_dns_incoming.count(nevents);
 }
 
 
index a3a16ff97e17af1bb9034d0f6d79cdd3088235db..c4eda9956ce0b21b4825d7726a003eae377ff615 100644 (file)
@@ -300,7 +300,7 @@ comm_select_icp_incoming(void)
     if (nevents > INCOMING_ICP_MAX)
         nevents = INCOMING_ICP_MAX;
 
-    statHistCount(&statCounter.comm_icp_incoming, nevents);
+    statCounter.comm_icp_incoming.count(nevents);
 }
 
 static void
@@ -331,7 +331,7 @@ comm_select_http_incoming(void)
     if (nevents > INCOMING_HTTP_MAX)
         nevents = INCOMING_HTTP_MAX;
 
-    statHistCount(&statCounter.comm_http_incoming, nevents);
+    statCounter.comm_http_incoming.count(nevents);
 }
 
 #define DEBUG_FDBITS 0
@@ -471,7 +471,7 @@ Comm::DoSelect(int msec)
 
         debugs(5, num ? 5 : 8, "comm_select: " << num << "+" << pending << " FDs ready");
 
-        statHistCount(&statCounter.select_fds_hist, num);
+        statCounter.select_fds_hist.count(num);
 
         if (num == 0 && pending == 0)
             continue;
@@ -661,7 +661,7 @@ comm_select_dns_incoming(void)
     if (nevents > INCOMING_DNS_MAX)
         nevents = INCOMING_DNS_MAX;
 
-    statHistCount(&statCounter.comm_dns_incoming, nevents);
+    statCounter.comm_dns_incoming.count(nevents);
 }
 
 void
index dd8a8aeb1dbb492f303af055ebf9937592847093..1c31c5954227507a1db072fedee6861ff8046703 100644 (file)
@@ -303,7 +303,7 @@ comm_select_icp_incoming(void)
     if (nevents > INCOMING_ICP_MAX)
         nevents = INCOMING_ICP_MAX;
 
-    statHistCount(&statCounter.comm_icp_incoming, nevents);
+    statCounter.comm_icp_incoming.count(nevents);
 }
 
 static void
@@ -334,7 +334,7 @@ comm_select_http_incoming(void)
     if (nevents > INCOMING_HTTP_MAX)
         nevents = INCOMING_HTTP_MAX;
 
-    statHistCount(&statCounter.comm_http_incoming, nevents);
+    statCounter.comm_http_incoming.count(nevents);
 }
 
 #define DEBUG_FDBITS 0
@@ -471,7 +471,7 @@ Comm::DoSelect(int msec)
 
         debugs(5, num ? 5 : 8, "comm_select: " << num << "+" << pending << " FDs ready");
 
-        statHistCount(&statCounter.select_fds_hist, num);
+        statCounter.select_fds_hist.count(num);
 
         if (num == 0 && pending == 0)
             continue;
@@ -683,7 +683,7 @@ comm_select_dns_incoming(void)
     if (nevents > INCOMING_DNS_MAX)
         nevents = INCOMING_DNS_MAX;
 
-    statHistCount(&statCounter.comm_dns_incoming, nevents);
+    statCounter.comm_dns_incoming.count(nevents);
 }
 
 void
index 375b7e4ee3f09c86e1c73813be5652f43043c7a2..b01d2434e49459f0c7bb095cb170cd63ea1d0993 100644 (file)
@@ -502,7 +502,7 @@ fqdncacheHandleReply(void *data, rfc1035_rr * answers, int na, const char *error
     static_cast<generic_cbdata *>(data)->unwrap(&f);
     ++FqdncacheStats.replies;
     const int age = f->age();
-    statHistCount(&statCounter.dns.svc_time, age);
+    statCounter.dns.svc_time.count(age);
 #if USE_DNSSERVERS
 
     fqdncacheParse(f, reply);
index e3992f199a55e382f37b797bddd676f9faac065e..b0835343c01beb6e6f890286a91795344a08aac9 100644 (file)
@@ -811,7 +811,7 @@ icpCount(void *buf, int which, size_t len, int delay)
             statCounter.icp.replies_sent++;
             kb_incr(&statCounter.icp.r_kbytes_sent, len);
             /* this is the sent-reply service time */
-            statHistCount(&statCounter.icp.reply_svc_time, delay);
+            statCounter.icp.reply_svc_time.count(delay);
         }
 
         if (ICP_HIT == icp->opcode)
index 97993d0b524b309dfbdb21f767dd8e642bdcf893..570d83f8ad8aac9c4459f29430687d61ff8353b5 100644 (file)
@@ -598,7 +598,7 @@ ipcacheHandleReply(void *data, rfc1035_rr * answers, int na, const char *error_m
     static_cast<generic_cbdata *>(data)->unwrap(&i);
     IpcacheStats.replies++;
     const int age = i->age();
-    statHistCount(&statCounter.dns.svc_time, age);
+    statCounter.dns.svc_time.count(age);
 
 #if USE_DNSSERVERS
     ipcacheParse(i, reply);
index 330bba5f20c3b45031264a46d5b09bba53fc6ac9..7ffe85840d0dcfe5f76785c94205c65db91a48e0 100644 (file)
@@ -10,7 +10,7 @@ statHistDump(const StatHist * H, StoreEntry * sentry, StatHistBinDumper * bd)
 }
 
 void
-statHistCount(StatHist * H, double val)
+StatHist::count(double val)
 {
     fatal("statHistCount: Not implemented");
 }