From 9bd0c79441a4ff5ffca4c14331ef1b1a80a575e5 Mon Sep 17 00:00:00 2001 From: jrandom Date: Sat, 29 Jul 2006 01:11:50 +0000 Subject: [PATCH] 2006-07-28 jrandom * Actually fix the threading deadlock issue in the netDb (removing the synchronized access to individual kbuckets while validating individual entries) (thanks cervantes, postman, frosk, et al!) --- history.txt | 7 ++++++- router/java/src/net/i2p/router/RouterVersion.java | 4 ++-- .../i2p/router/networkdb/kademlia/KBucketSet.java | 12 ++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/history.txt b/history.txt index 41fbd2a57..1dad21e06 100644 --- a/history.txt +++ b/history.txt @@ -1,4 +1,9 @@ -$Id: history.txt,v 1.499 2006-07-27 18:40:02 jrandom Exp $ +$Id: history.txt,v 1.500 2006-07-27 22:34:59 jrandom Exp $ + +2006-07-28 jrandom + * Actually fix the threading deadlock issue in the netDb (removing + the synchronized access to individual kbuckets while validating + individual entries) (thanks cervantes, postman, frosk, et al!) * 2006-07-27 0.6.1.23 released diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 8f05747fb..79c947641 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -15,9 +15,9 @@ import net.i2p.CoreVersion; * */ public class RouterVersion { - public final static String ID = "$Revision: 1.438 $ $Date: 2006-07-27 18:40:03 $"; + public final static String ID = "$Revision: 1.439 $ $Date: 2006-07-27 22:35:00 $"; public final static String VERSION = "0.6.1.23"; - public final static long BUILD = 0; + public final static long BUILD = 1; public static void main(String args[]) { System.out.println("I2P Router version: " + VERSION + "-" + BUILD); System.out.println("Router ID: " + RouterVersion.ID); diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/KBucketSet.java b/router/java/src/net/i2p/router/networkdb/kademlia/KBucketSet.java index b12feb3d4..6b3ca79d6 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/KBucketSet.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/KBucketSet.java @@ -28,6 +28,7 @@ class KBucketSet { private I2PAppContext _context; private Hash _us; private KBucket _buckets[]; + private volatile int _size; public final static int BASE = 8; // must go into KEYSIZE_BITS evenly public final static int KEYSIZE_BITS = Hash.HASH_LENGTH * 8; @@ -51,6 +52,8 @@ class KBucketSet { if (bucket >= 0) { int oldSize = _buckets[bucket].getKeyCount(); int numInBucket = _buckets[bucket].add(peer); + if (numInBucket != oldSize) + _size++; if (numInBucket > BUCKET_SIZE) { // perhaps queue up coalesce job? naaahh.. lets let 'er grow for now } @@ -62,17 +65,26 @@ class KBucketSet { } } + /** + * Not an exact count (due to concurrency issues) but generally correct + * + */ public int size() { + return _size; + /* int size = 0; for (int i = 0; i < _buckets.length; i++) size += _buckets[i].getKeyCount(); return size; + */ } public boolean remove(Hash entry) { int bucket = pickBucket(entry); KBucket kbucket = getBucket(bucket); boolean removed = kbucket.remove(entry); + if (removed) + _size--; return removed; }