I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 434b9fa0 authored by zzz's avatar zzz
Browse files

GeoIP: Thread the periodic lookup so it doesn't clog the timer queue

parent 56116ad8
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,7 @@ import net.i2p.router.RouterContext;
import net.i2p.router.transport.udp.UDPTransport;
import net.i2p.router.util.EventLog;
import net.i2p.util.Addresses;
import net.i2p.util.I2PThread;
import net.i2p.util.Log;
import net.i2p.util.SimpleTimer;
import net.i2p.util.SimpleTimer2;
......@@ -223,6 +224,7 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
/* We hope the routerinfos are read in and things have settled down by now, but it's not required to be so */
private static final int START_DELAY = 5*60*1000;
private static final int LOOKUP_TIME = 30*60*1000;
private void startGeoIP() {
_context.simpleScheduler().addEvent(new QueueAll(), START_DELAY);
}
......@@ -248,7 +250,26 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
private class Lookup implements SimpleTimer.TimedEvent {
public void timeReached() {
(new LookupThread()).start();
}
}
/**
* This takes too long to run on the SimpleTimer2 queue
* @since 0.9.10
*/
private class LookupThread extends I2PThread {
public LookupThread() {
super("GeoIP Lookup");
setDaemon(true);
}
public void run() {
long start = System.currentTimeMillis();
_geoIP.blockingLookup();
if (_log.shouldLog(Log.INFO))
_log.info("GeoIP lookup took " + (System.currentTimeMillis() - start));
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment