From 49a6cdbda6880ea7064aebd8a52bfd3494805d10 Mon Sep 17 00:00:00 2001 From: zzz Date: Sun, 14 Feb 2010 01:17:19 +0000 Subject: [PATCH] - Clear the geoip negative cache periodically --- router/java/src/net/i2p/router/transport/GeoIP.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/router/java/src/net/i2p/router/transport/GeoIP.java b/router/java/src/net/i2p/router/transport/GeoIP.java index 93ddfe215..cc0a63ba6 100644 --- a/router/java/src/net/i2p/router/transport/GeoIP.java +++ b/router/java/src/net/i2p/router/transport/GeoIP.java @@ -43,6 +43,7 @@ public class GeoIP { private final Set _pendingSearch; private final Set _notFound; private final AtomicBoolean _lock; + private int _lookupRunCount; public GeoIP(RouterContext context) { _context = context; @@ -92,9 +93,14 @@ public class GeoIP { } private class LookupJob implements Runnable { + private static final int CLEAR = 8; + public void run() { if (_lock.getAndSet(true)) return; + // clear the negative cache every few runs, to prevent it from getting too big + if (((++_lookupRunCount) % CLEAR) == 0) + _notFound.clear(); Long[] search = _pendingSearch.toArray(new Long[_pendingSearch.size()]); if (search.length <= 0) return;