From ee4d68cf6a91686c64eaee3c94643cf00f47d10d Mon Sep 17 00:00:00 2001
From: zzz <zzz@mail.i2p>
Date: Fri, 29 Aug 2008 13:13:45 +0000
Subject: [PATCH]     * Stats: Remove tunnel.Bps.* stats when the tunnel pool
 is closed

---
 core/java/src/net/i2p/stat/StatManager.java                | 7 +++++++
 router/java/src/net/i2p/router/tunnel/pool/TunnelPool.java | 1 +
 2 files changed, 8 insertions(+)

diff --git a/core/java/src/net/i2p/stat/StatManager.java b/core/java/src/net/i2p/stat/StatManager.java
index 3f3ab4a723..fc1b18fdf0 100644
--- a/core/java/src/net/i2p/stat/StatManager.java
+++ b/core/java/src/net/i2p/stat/StatManager.java
@@ -112,6 +112,13 @@ public class StatManager {
         }
     }
 
+    // Hope this doesn't cause any problems with unsynchronized accesses like addRateData() ...
+    public void removeRateStat(String name) {
+        synchronized (_rateStats) {
+            _rateStats.remove(name);
+        }
+    }
+
     /** update the given frequency statistic, taking note that an event occurred (and recalculating all frequencies) */
     public void updateFrequency(String name) {
         FrequencyStat freq = (FrequencyStat) _frequencyStats.get(name);
diff --git a/router/java/src/net/i2p/router/tunnel/pool/TunnelPool.java b/router/java/src/net/i2p/router/tunnel/pool/TunnelPool.java
index 7267b26a1a..e8740ccc72 100644
--- a/router/java/src/net/i2p/router/tunnel/pool/TunnelPool.java
+++ b/router/java/src/net/i2p/router/tunnel/pool/TunnelPool.java
@@ -89,6 +89,7 @@ public class TunnelPool {
         _alive = false;
         _lastSelectionPeriod = 0;
         _lastSelected = null;
+        _context.statManager().removeRateStat(_rateName);
     }
 
     TunnelPoolManager getManager() { return _manager; }
-- 
GitLab