Author: toad
Date: 2008-04-03 18:16:48 +0000 (Thu, 03 Apr 2008)
New Revision: 18961
Modified:
trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
Log:
Fix deadlock. Everywhere else, we schedule outside the segment lock. We should
do so here too.
Modified: trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
2008-04-03 15:36:38 UTC (rev 18960)
+++ trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
2008-04-03 18:16:48 UTC (rev 18961)
@@ -580,9 +580,11 @@
return checkCooldownTimes[blockNum - dataKeys.length];
}
- public synchronized void requeueAfterCooldown(Key key, long time) {
+ public void requeueAfterCooldown(Key key, long time) {
+ Vector v = null;
+ boolean notFound = true;
+ synchronized(this) {
if(isFinishing()) return;
- boolean notFound = true;
int maxTries = blockFetchContext.maxNonSplitfileRetries;
for(int i=0;i<dataKeys.length;i++) {
if(dataKeys[i] == null) continue;
@@ -596,7 +598,9 @@
SplitFileFetcherSubSegment sub =
getSubSegment(tries);
if(logMINOR)
Logger.minor(this, "Retrying after
cooldown on "+this+": data block "+i+" on "+this+" :
tries="+tries+"/"+maxTries+" : "+sub);
- sub.add(i, false);
+ if(v == null) v = new Vector();
+ sub.add(i, true);
+ if(!v.contains(sub)) v.add(sub);
notFound = false;
}
}
@@ -612,13 +616,21 @@
SplitFileFetcherSubSegment sub =
getSubSegment(tries);
if(logMINOR)
Logger.minor(this, "Retrying after
cooldown on "+this+": check block "+i+" on "+this+" :
tries="+tries+"/"+maxTries+" : "+sub);
- sub.add(i+dataKeys.length, false);
+ if(v == null) v = new Vector();
+ sub.add(i+dataKeys.length, true);
+ if(!v.contains(sub)) v.add(sub);
notFound = false;
}
}
+ }
if(notFound) {
Logger.error(this, "requeueAfterCooldown: Key not
found!: "+key+" on "+this);
}
+ if(v != null) {
+ for(int i=0;i<v.size();i++) {
+ ((SplitFileFetcherSubSegment)
v.get(i)).schedule();
+ }
+ }
}
public synchronized long getCooldownWakeupByKey(Key key) {