forked from I2P_Developers/i2p.i2p
Router: Soft restart fixes part 1
Reset uptime on soft restart Don't rekey after failure to store our RI due to clock skew Change comm system state during soft restart Restarter log tweaks
This commit is contained in:
@ -1826,8 +1826,9 @@ public class Router implements RouterClock.ClockShiftListener {
|
||||
changeState(State.RESTARTING);
|
||||
}
|
||||
((RouterClock) _context.clock()).removeShiftListener(this);
|
||||
// Let's not stop accepting tunnels, etc
|
||||
//_started = _context.clock().now();
|
||||
// Stop accepting tunnels, etc.
|
||||
// This also prevents netdb from immediately expiring all the RIs
|
||||
_started = System.currentTimeMillis();
|
||||
synchronized(_configFileLock) {
|
||||
_downtime = 1;
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ package net.i2p.router.tasks;
|
||||
*
|
||||
*/
|
||||
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.data.router.RouterInfo;
|
||||
import net.i2p.router.Router;
|
||||
import net.i2p.router.RouterContext;
|
||||
@ -27,12 +28,25 @@ public class Republish implements SimpleTimer.TimedEvent {
|
||||
}
|
||||
|
||||
public void timeReached() {
|
||||
RouterInfo ri = null;
|
||||
try {
|
||||
RouterInfo ri = _context.router().getRouterInfo();
|
||||
ri = _context.router().getRouterInfo();
|
||||
if (ri != null)
|
||||
_context.netDb().publish(ri);
|
||||
} catch (IllegalArgumentException iae) {
|
||||
Log log = _context.logManager().getLog(Router.class);
|
||||
// clock skew / shift race?
|
||||
if (ri != null) {
|
||||
long now = _context.clock().now();
|
||||
long published = ri.getDate();
|
||||
long diff = Math.abs(now - published);
|
||||
if (diff > 60*1000) {
|
||||
log.logAlways(Log.WARN, "Clock skift, rebuilding router info: " + DataHelper.formatDuration(diff));
|
||||
// let's just try this again and hope for better results
|
||||
_context.router().rebuildRouterInfo();
|
||||
return;
|
||||
}
|
||||
}
|
||||
log.log(Log.CRIT, "Local router info is invalid? rebuilding a new identity", iae);
|
||||
_context.router().rebuildNewIdentity();
|
||||
}
|
||||
|
@ -28,19 +28,18 @@ public class Restarter implements Runnable {
|
||||
_context.bandwidthLimiter().reinitialize();
|
||||
try { _context.messageRegistry().restart(); } catch (Throwable t) { log.log(Log.CRIT, "Error restarting the message registry", t); }
|
||||
try { _context.commSystem().restart(); } catch (Throwable t) { log.log(Log.CRIT, "Error restarting the comm system", t); }
|
||||
log.logAlways(Log.WARN, "Restarted the comm system");
|
||||
log.logAlways(Log.WARN, "Stopping the tunnel manager");
|
||||
try { _context.tunnelManager().restart(); } catch (Throwable t) { log.log(Log.CRIT, "Error restarting the tunnel manager", t); }
|
||||
log.logAlways(Log.WARN, "Restarted the tunnel manager");
|
||||
|
||||
//try { _context.peerManager().restart(); } catch (Throwable t) { log.log(Log.CRIT, "Error restarting the peer manager", t); }
|
||||
//try { _context.netDb().restart(); } catch (Throwable t) { log.log(Log.CRIT, "Error restarting the networkDb", t); }
|
||||
//try { _context.jobQueue().restart(); } catch (Throwable t) { log.log(Log.CRIT, "Error restarting the job queue", t); }
|
||||
|
||||
log.logAlways(Log.WARN, "Router teardown complete, restarting the router...");
|
||||
try { Thread.sleep(10*1000); } catch (InterruptedException ie) {}
|
||||
_context.router().setEstimatedDowntime(System.currentTimeMillis() - start);
|
||||
|
||||
log.logAlways(Log.WARN, "Restarting the comm system");
|
||||
log.logAlways(Log.WARN, "Restarting the tunnel manager");
|
||||
log.logAlways(Log.WARN, "Restarting the client manager");
|
||||
try { _context.clientMessagePool().restart(); } catch (Throwable t) { log.log(Log.CRIT, "Error restarting the CMP", t); }
|
||||
try { _context.clientManager().startup(); } catch (Throwable t) { log.log(Log.CRIT, "Error starting the client manager", t); }
|
||||
|
@ -82,10 +82,13 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
|
||||
}
|
||||
|
||||
public synchronized void restart() {
|
||||
if (!_wasStarted)
|
||||
if (!_wasStarted) {
|
||||
startup();
|
||||
else
|
||||
} else {
|
||||
_wasStarted = false;
|
||||
_manager.restart();
|
||||
_wasStarted = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user