Changeset 434b9fa0


Ignore:
Timestamp:
Nov 26, 2013 4:28:24 PM (6 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
7b0b079
Parents:
56116ad
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/transport/CommSystemFacadeImpl.java

    r56116ad r434b9fa0  
    2727import net.i2p.router.util.EventLog;
    2828import net.i2p.util.Addresses;
     29import net.i2p.util.I2PThread;
    2930import net.i2p.util.Log;
    3031import net.i2p.util.SimpleTimer;
     
    224225    private static final int START_DELAY = 5*60*1000;
    225226    private static final int LOOKUP_TIME = 30*60*1000;
     227
    226228    private void startGeoIP() {
    227229        _context.simpleScheduler().addEvent(new QueueAll(), START_DELAY);
     
    249251    private class Lookup implements SimpleTimer.TimedEvent {
    250252        public void timeReached() {
     253            (new LookupThread()).start();
     254        }
     255    }
     256
     257    /**
     258     *  This takes too long to run on the SimpleTimer2 queue
     259     *  @since 0.9.10
     260     */
     261    private class LookupThread extends I2PThread {
     262
     263        public LookupThread() {
     264            super("GeoIP Lookup");
     265            setDaemon(true);
     266        }
     267
     268        public void run() {
     269            long start = System.currentTimeMillis();
    251270            _geoIP.blockingLookup();
     271            if (_log.shouldLog(Log.INFO))
     272                _log.info("GeoIP lookup took " + (System.currentTimeMillis() - start));
    252273        }
    253274    }
Note: See TracChangeset for help on using the changeset viewer.