Author: toad
Date: 2008-08-29 21:34:55 +0000 (Fri, 29 Aug 2008)
New Revision: 22223
Modified:
branches/db4o/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
Log:
Synchronize onGotKeys() to prevent two onGotKey's running in parallel both
returning true -> double remove from Bloom filter.
Modified:
branches/db4o/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
2008-08-29 21:31:54 UTC (rev 22222)
+++ branches/db4o/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
2008-08-29 21:34:55 UTC (rev 22223)
@@ -1130,8 +1130,13 @@
/**
* @return True if we fetched a block.
+ * Hold the lock for the whole duration of this method. If a transient
request
+ * has two copies of onGotKey() run in parallel, we want only one of
them to
+ * return true, otherwise SFFKL will remove the keys from the main bloom
+ * filter twice, resulting in collateral damage to other overlapping
keys,
+ * and then "NOT IN BLOOM FILTER" errors, or worse, false negatives.
*/
- public boolean onGotKey(Key key, KeyBlock block, ObjectContainer
container, ClientContext context) {
+ public synchronized boolean onGotKey(Key key, KeyBlock block,
ObjectContainer container, ClientContext context) {
int blockNum = this.getBlockNumber(key, container);
if(blockNum < 0) return false;
ClientCHK ckey = this.getBlockKey(blockNum, container);