From c01bf47c8a64c3b80403562177d25badd57775a9 Mon Sep 17 00:00:00 2001 From: zzz Date: Wed, 5 Jun 2019 17:37:23 +0000 Subject: [PATCH] NetDb: Fix to set netDb ready immediately after reseed --- .../networkdb/kademlia/PersistentDataStore.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/PersistentDataStore.java b/router/java/src/net/i2p/router/networkdb/kademlia/PersistentDataStore.java index 50c7e0995..e8e7419ed 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/PersistentDataStore.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/PersistentDataStore.java @@ -343,6 +343,7 @@ public class PersistentDataStore extends TransientDataStore { private class ReadJob extends JobImpl { private volatile long _lastModified; private volatile long _lastReseed; + private volatile boolean _setNetDbReady; private static final int MIN_ROUTERS = KademliaNetworkDatabaseFacade.MIN_RESEED; private static final long MIN_RESEED_INTERVAL = 90*60*1000; @@ -457,6 +458,7 @@ public class PersistentDataStore extends TransientDataStore { _lastReseed = _context.clock().now(); // checkReseed will call wakeup() when done and we will run again } else { + _setNetDbReady = true; _context.router().setNetDbReady(); } } else if (_lastReseed < _context.clock().now() - MIN_RESEED_INTERVAL) { @@ -466,7 +468,19 @@ public class PersistentDataStore extends TransientDataStore { _lastReseed = _context.clock().now(); // checkReseed will call wakeup() when done and we will run again } else { - _context.router().setNetDbReady(); + if (!_setNetDbReady) { + _setNetDbReady = true; + _context.router().setNetDbReady(); + } + } + } else { + // second time through, reseed called wakeup() + if (!_setNetDbReady) { + int count = Math.min(routerCount, size()); + if (count >= MIN_ROUTERS) { + _setNetDbReady = true; + _context.router().setNetDbReady(); + } } } }