Author: toad
Date: 2008-05-15 21:23:49 +0000 (Thu, 15 May 2008)
New Revision: 19951
Modified:
trunk/freenet/src/freenet/client/async/USKFetcher.java
Log:
Don't hold the USKFetcher lock while decoding the lastdata.
The USKFetcher lock can be taken on the UdpSocketHandler thread, so it should
not block for I/O: we have seen this cause contention, and result in the
UdpSocketHandler watchdog forcing a restart.
Modified: trunk/freenet/src/freenet/client/async/USKFetcher.java
===================================================================
--- trunk/freenet/src/freenet/client/async/USKFetcher.java 2008-05-15
19:57:36 UTC (rev 19950)
+++ trunk/freenet/src/freenet/client/async/USKFetcher.java 2008-05-15
21:23:49 UTC (rev 19951)
@@ -295,25 +295,12 @@
LinkedList l = null;
final long lastEd = uskManager.lookup(origUSK);
long curLatest;
+ boolean decode = false;
synchronized(this) {
runningAttempts.remove(att);
curLatest = att.number;
if(completed || cancelled) return;
- if(curLatest >= lastEd && !(dontUpdate && block ==
null)) {
- try {
- Bucket data = lastRequestData =
block.decode(ctx.bucketFactory, 1025 /* it's an SSK */, true);
- lastCompressionCodec =
block.getCompressionCodec();
- lastWasMetadata = block.isMetadata();
- if(keepLastData)
- lastRequestData = data;
- else
- data.free();
- } catch (KeyDecodeException e) {
- lastRequestData = null;
- } catch (IOException e) {
- lastRequestData = null;
- }
- }
+ decode = curLatest >= lastEd && !(dontUpdate && block
== null);
curLatest = Math.max(lastEd, curLatest);
if(logMINOR) Logger.minor(this, "Latest: "+curLatest);
long addTo = curLatest + minFailures;
@@ -328,6 +315,26 @@
}
cancelBefore(curLatest);
}
+ Bucket data = null;
+ if(decode) {
+ try {
+ data = lastRequestData =
block.decode(ctx.bucketFactory, 1025 /* it's an SSK */, true);
+ } catch (KeyDecodeException e) {
+ data = null;
+ } catch (IOException e) {
+ data = null;
+ }
+ }
+ synchronized(this) {
+ if(curLatest >= lastEd && !(dontUpdate && data ==
null)) {
+ lastCompressionCodec =
block.getCompressionCodec();
+ lastWasMetadata = block.isMetadata();
+ if(keepLastData)
+ lastRequestData = data;
+ else
+ data.free();
+ }
+ }
if(!dontUpdate)
uskManager.update(origUSK, curLatest);
if(l == null) return;