Author: toad
Date: 2008-01-12 20:58:11 +0000 (Sat, 12 Jan 2008)
New Revision: 17031
Modified:
trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
Log:
Synchronization (maybe fix deadlock): Do not call onFatalFailure() and
therefore fail() inside a lock on (this).
Modified: trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
2008-01-12 20:27:36 UTC (rev 17030)
+++ trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
2008-01-12 20:58:11 UTC (rev 17031)
@@ -363,22 +363,21 @@
public void onNonFatalFailure(FetchException e, int blockNo,
SplitFileFetcherSubSegment seg) {
int tries;
int maxTries = blockFetchContext.maxNonSplitfileRetries;
+ boolean failed = false;
synchronized(this) {
if(isFinished()) return;
if(blockNo < dataKeys.length) {
tries = ++dataRetries[blockNo];
- if(tries > maxTries && maxTries >= 0) {
- onFatalFailure(e, blockNo, seg);
- return;
- }
+ if(tries > maxTries && maxTries >= 0) failed =
true;
} else {
tries = ++checkRetries[blockNo-dataKeys.length];
- if(tries > maxTries && maxTries >= 0) {
- onFatalFailure(e, blockNo, seg);
- return;
- }
+ if(tries > maxTries && maxTries >= 0) failed =
true;
}
}
+ if(failed) {
+ onFatalFailure(e, blockNo, seg);
+ return;
+ }
// If we are here we are going to retry
SplitFileFetcherSubSegment sub = getSubSegment(tries);
if(logMINOR)