From: Francesco Chemolli Date: Tue, 6 Dec 2011 14:24:47 +0000 (+0100) Subject: Migrated statHistCount callers to StatHist::count X-Git-Tag: BumpSslServerFirst.take05~12^2~120^2~22 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f30f79985857687870b7d6d071a299fbf65b0f02;p=thirdparty%2Fsquid.git Migrated statHistCount callers to StatHist::count --- diff --git a/src/CacheDigest.cc b/src/CacheDigest.cc index 9f649cd5f2..ac26bde4f8 100644 --- a/src/CacheDigest.cc +++ b/src/CacheDigest.cc @@ -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++; diff --git a/src/HttpHdrCc.cc b/src/HttpHdrCc.cc index a913c9dc51..1939ad66ad 100644 --- a/src/HttpHdrCc.cc +++ b/src/HttpHdrCc.cc @@ -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 diff --git a/src/HttpHdrScTarget.cc b/src/HttpHdrScTarget.cc index 1639ccb76e..aac03689ac 100644 --- a/src/HttpHdrScTarget.cc +++ b/src/HttpHdrScTarget.cc @@ -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); } diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index ab9cdc44f1..ca2e71a932 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -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; } diff --git a/src/StatHist.cc b/src/StatHist.cc index e9f8c8fef6..e3b4b779af 100644 --- a/src/StatHist.cc +++ b/src/StatHist.cc @@ -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 diff --git a/src/StatHist.h b/src/StatHist.h index e853d42556..7299807403 100644 --- a/src/StatHist.h +++ b/src/StatHist.h @@ -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); diff --git a/src/client_side.cc b/src/client_side.cc index e4fe532061..069bbeb66f 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -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++; diff --git a/src/comm/ModDevPoll.cc b/src/comm/ModDevPoll.cc index 5c790ec206..ab39bb00de 100644 --- a/src/comm/ModDevPoll.cc +++ b/src/comm/ModDevPoll.cc @@ -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 */ diff --git a/src/comm/ModEpoll.cc b/src/comm/ModEpoll.cc index 51e6a86e80..f0e01d8612 100644 --- a/src/comm/ModEpoll.cc +++ b/src/comm/ModEpoll.cc @@ -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.. */ diff --git a/src/comm/ModPoll.cc b/src/comm/ModPoll.cc index ecc950ea84..8004d33eae 100644 --- a/src/comm/ModPoll.cc +++ b/src/comm/ModPoll.cc @@ -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); } diff --git a/src/comm/ModSelect.cc b/src/comm/ModSelect.cc index a3a16ff97e..c4eda9956c 100644 --- a/src/comm/ModSelect.cc +++ b/src/comm/ModSelect.cc @@ -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 diff --git a/src/comm/ModSelectWin32.cc b/src/comm/ModSelectWin32.cc index dd8a8aeb1d..1c31c59542 100644 --- a/src/comm/ModSelectWin32.cc +++ b/src/comm/ModSelectWin32.cc @@ -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 diff --git a/src/fqdncache.cc b/src/fqdncache.cc index 375b7e4ee3..b01d2434e4 100644 --- a/src/fqdncache.cc +++ b/src/fqdncache.cc @@ -502,7 +502,7 @@ fqdncacheHandleReply(void *data, rfc1035_rr * answers, int na, const char *error static_cast(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); diff --git a/src/icp_v2.cc b/src/icp_v2.cc index e3992f199a..b0835343c0 100644 --- a/src/icp_v2.cc +++ b/src/icp_v2.cc @@ -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) diff --git a/src/ipcache.cc b/src/ipcache.cc index 97993d0b52..570d83f8ad 100644 --- a/src/ipcache.cc +++ b/src/ipcache.cc @@ -598,7 +598,7 @@ ipcacheHandleReply(void *data, rfc1035_rr * answers, int na, const char *error_m static_cast(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); diff --git a/src/tests/stub_StatHist.cc b/src/tests/stub_StatHist.cc index 330bba5f20..7ffe85840d 100644 --- a/src/tests/stub_StatHist.cc +++ b/src/tests/stub_StatHist.cc @@ -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"); }