]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
- added statHistSafeCopy for copying histograms with variable capacity
authorrousskov <>
Mon, 27 Apr 1998 23:25:01 +0000 (23:25 +0000)
committerrousskov <>
Mon, 27 Apr 1998 23:25:01 +0000 (23:25 +0000)
  statHistSafeCopy will not copy old values if capacities differ
  statHistSafeCopy is a hack, but "general" solution is hard to find

src/StatHist.cc
src/protos.h
src/stat.cc

index 67de7b1c38bc23696f8ef2b16d44e66ccf16800e..1fec8723e8a5ad24bc19938750ab57a649993fae 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: StatHist.cc,v 1.7 1998/04/24 07:09:28 wessels Exp $
+ * $Id: StatHist.cc,v 1.8 1998/04/27 17:25:03 rousskov Exp $
  *
  * DEBUG: section 62    Generic Histogram
  * AUTHOR: Duane Wessels
@@ -98,6 +98,20 @@ statHistCopy(StatHist * Dest, const StatHist * Orig)
     xmemcpy(Dest->bins, Orig->bins, Dest->capacity * sizeof(*Dest->bins));
 }
 
+/*
+ * 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)
+       statHistCopy(Dest, Orig);
+}
+
 void
 statHistCount(StatHist * H, double val)
 {
index 5f26c69bc6645d097623fe5fac0ff310e8b195af..20933f50f5f9051405efde828947a048df9b5e88 100644 (file)
@@ -556,15 +556,16 @@ extern void statInit(void);
 extern double median_svc_get(int, int);
 extern void pconnHistCount(int, int);
 
-void statHistClean(StatHist * H);
-void statHistCount(StatHist * H, double val);
-void statHistCopy(StatHist * Dest, const StatHist * Orig);
-double statHistDeltaMedian(const StatHist * A, const StatHist * B);
-void statHistDump(const StatHist * H, StoreEntry * sentry, StatHistBinDumper bd);
-void statHistLogInit(StatHist * H, int capacity, double min, double max);
-void statHistEnumInit(StatHist * H, int last_enum);
-void statHistIntDumper(StoreEntry * sentry, int idx, double val, double size, int count);
-
+/* StatHist */
+extern void statHistClean(StatHist * H);
+extern void statHistCount(StatHist * H, double val);
+extern void statHistCopy(StatHist * Dest, const StatHist * Orig);
+extern void statHistSafeCopy(StatHist * Dest, const StatHist * Orig);
+extern double statHistDeltaMedian(const StatHist * A, const StatHist * B);
+extern void statHistDump(const StatHist * H, StoreEntry * sentry, StatHistBinDumper bd);
+extern void statHistLogInit(StatHist * H, int capacity, double min, double max);
+extern void statHistEnumInit(StatHist * H, int last_enum);
+extern void statHistIntDumper(StoreEntry * sentry, int idx, double val, double size, int count);
 
 /* MemMeter */
 extern void memMeterSyncHWater(MemMeter * m);
index 76749ea27a0e8ae36c4aea315b7ee577e71d00a2..74dcd1cfb5ce71d81a5677e6a79ae7254cedd65c 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: stat.cc,v 1.244 1998/04/24 06:08:21 wessels Exp $
+ * $Id: stat.cc,v 1.245 1998/04/27 17:25:01 rousskov Exp $
  *
  * DEBUG: section 18    Cache Manager Statistics
  * AUTHOR: Harvest Derived
@@ -936,8 +936,8 @@ statCountersCopy(StatCounters * dest, const StatCounters * orig)
     statHistCopy(&dest->icp.client_svc_time, &orig->icp.client_svc_time);
     statHistCopy(&dest->cd.server_svc_time, &orig->cd.server_svc_time);
     statHistCopy(&dest->icp.server_svc_time, &orig->icp.server_svc_time);
-    statHistCopy(&dest->cd.peer_choice_count, &orig->cd.peer_choice_count);
-    statHistCopy(&dest->cd.peer_ichoice_count, &orig->cd.peer_ichoice_count);
+    statHistSafeCopy(&dest->cd.peer_choice_count, &orig->cd.peer_choice_count);
+    statHistSafeCopy(&dest->cd.peer_ichoice_count, &orig->cd.peer_ichoice_count);
     statHistCopy(&dest->cd.on_xition_count, &orig->cd.on_xition_count);
 #endif
 }