From f46a902256b0095eb73f05f8bf449a2f71f24db0 Mon Sep 17 00:00:00 2001 From: dg2-new <dg2-new@mail.i2p> Date: Sun, 27 Sep 2015 21:15:51 +0000 Subject: [PATCH] Router: Fix soft restarts for 'massive' clock jumps (over +150s or -61s) and recover from standby/hibernate (ticket #1014). I2P should now recover (better) from a system hibernate/standby and be able to reconnect to peers automatically. --- history.txt | 2 ++ router/java/src/net/i2p/router/Router.java | 6 ++++-- router/java/src/net/i2p/router/RouterVersion.java | 2 +- router/java/src/net/i2p/router/tasks/Restarter.java | 4 ++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/history.txt b/history.txt index 3633628324..a9580a1929 100644 --- a/history.txt +++ b/history.txt @@ -9,6 +9,8 @@ * Tunnels: Use max of 2 not-failing peers in an exploratory tunnel, use high cap for the rest; change outbound exploratory default length from 2 + 0-1 to 3+0. + * Router: Fix soft restarts for 'massive' clock jumps (over +150s or -61s) and recover from standby + and hibernate (ticket #1014). 2015-09-25 dg * Rename _() for translation to _t() for Java 9 compatibility (ticket #1456) diff --git a/router/java/src/net/i2p/router/Router.java b/router/java/src/net/i2p/router/Router.java index a76d4b7fab..fd68b7b698 100644 --- a/router/java/src/net/i2p/router/Router.java +++ b/router/java/src/net/i2p/router/Router.java @@ -1443,8 +1443,10 @@ public class Router implements RouterClock.ClockShiftListener { _eventLog.addEvent(EventLog.CLOCK_SHIFT, Long.toString(delta)); // update the routing key modifier _context.routerKeyGenerator().generateDateBasedModData(); - if (_context.commSystem().countActivePeers() <= 0) - return; + // Commented because this check makes no sense (#1014) + // .. and 'active' is relative to our broken time. + //if (_context.commSystem().countActivePeers() <= 0) + // return; if (delta > 0) _log.error("Restarting after large clock shift forward by " + DataHelper.formatDuration(delta)); else diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 7ca1a3ec2c..5a58b19bc2 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,7 +18,7 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 10; + public final static long BUILD = 11; /** for example "-test" */ public final static String EXTRA = ""; diff --git a/router/java/src/net/i2p/router/tasks/Restarter.java b/router/java/src/net/i2p/router/tasks/Restarter.java index c904cad507..23991ae0e1 100644 --- a/router/java/src/net/i2p/router/tasks/Restarter.java +++ b/router/java/src/net/i2p/router/tasks/Restarter.java @@ -30,9 +30,9 @@ public class Restarter implements Runnable { 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); } - //try { _context.peerManager().restart(); } catch (Throwable t) { log.log(Log.CRIT, "Error restarting the peer manager", t); } + 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); } + 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) {} -- GitLab