2005-02-24 jrandom

* Throttle the number of tunnel rebuilds per minute, preventing CPU
      overload under catastrophic failures (thanks Tracker and cervantes!)
    * Block the router startup process until we've initialized the clock
This commit is contained in:
jrandom
2005-02-24 23:53:35 +00:00
committed by zzz
parent 00f27d4400
commit 4cec9da0a6
5 changed files with 84 additions and 7 deletions

View File

@ -101,6 +101,15 @@ public class Timestamper implements Runnable {
t.start();
}
public void waitForInitialization() {
try {
synchronized (this) {
if (!_initialized)
wait();
}
} catch (InterruptedException ie) {}
}
public void run() {
try { Thread.sleep(1000); } catch (InterruptedException ie) {}
_log = _context.logManager().getLog(Timestamper.class);
@ -130,6 +139,9 @@ public class Timestamper implements Runnable {
lastFailed = true;
}
}
_initialized = true;
synchronized (this) { notifyAll(); }
long sleepTime = _context.random().nextInt(_queryFrequency) + _queryFrequency;
if (lastFailed)
sleepTime = 30*1000;
@ -137,6 +149,7 @@ public class Timestamper implements Runnable {
}
} catch (Throwable t) {
_log.log(Log.CRIT, "Timestamper died!", t);
synchronized (this) { notifyAll(); }
}
}