forked from I2P_Developers/i2p.i2p
* NetDb: Fix a deadlock caused by last checkin
This commit is contained in:
@@ -269,8 +269,9 @@ public class FloodfillNetworkDatabaseFacade extends KademliaNetworkDatabaseFacad
|
||||
// following are some special situations, we don't want to
|
||||
// drop the peer in these cases
|
||||
// yikes don't do this - stack overflow // getFloodfillPeers().size() == 0 ||
|
||||
// yikes2 don't do this either - deadlock! // getKnownRouters() < MIN_REMAINING_ROUTERS ||
|
||||
if (info.getNetworkId() == Router.NETWORK_ID &&
|
||||
(getKnownRouters() < MIN_REMAINING_ROUTERS ||
|
||||
(getKBucketSetSize() < MIN_REMAINING_ROUTERS ||
|
||||
_context.router().getUptime() < DONT_FAIL_PERIOD ||
|
||||
_context.commSystem().countActivePeers() <= MIN_ACTIVE_PEERS)) {
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
|
@@ -420,6 +420,16 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is fast and doesn't use synchronization,
|
||||
* but it includes both routerinfos and leasesets.
|
||||
* Use it to avoid deadlocks.
|
||||
*/
|
||||
protected int getKBucketSetSize() {
|
||||
if (_kb == null) return 0;
|
||||
return _kb.size();
|
||||
}
|
||||
|
||||
public void lookupLeaseSet(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs) {
|
||||
if (!_initialized) return;
|
||||
LeaseSet ls = lookupLeaseSetLocally(key);
|
||||
|
Reference in New Issue
Block a user