Author: toad
Date: 2008-02-22 20:14:09 +0000 (Fri, 22 Feb 2008)
New Revision: 18108
Modified:
trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
trunk/freenet/src/freenet/client/async/SplitFileFetcherSubSegment.java
Log:
Make allKeys() return *ALL* keys at a given retry level.
Including those on the coalescing queue or which are being requested.
So they can be removed immediately in removePendingKeys(SendableGet,boolean).
This prevents memory leaks, and the Key not found! error on requeueing after
cooldown.
Previous commit also prevents memory wastage and the segment finished but
didn't tell us error message.
Modified: trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
2008-02-22 20:08:35 UTC (rev 18107)
+++ trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
2008-02-22 20:14:09 UTC (rev 18108)
@@ -594,4 +594,19 @@
if(checkKeys[i] != null &&
checkKeys[i].getNodeKey().equals(key)) return dataKeys.length+i;
return -1;
}
+
+ public synchronized Integer[] getKeyNumbersAtRetryLevel(int retryCount)
{
+ Vector v = new Vector();
+ for(int i=0;i<dataRetries.length;i++) {
+ if(dataKeys[i] == null) continue;
+ if(dataRetries[i] == retryCount)
+ v.add(new Integer(i));
+ }
+ for(int i=0;i<checkRetries.length;i++) {
+ if(checkKeys[i] == null) continue;
+ if(checkRetries[i] == retryCount)
+ v.add(new Integer(i+dataKeys.length));
+ }
+ return (Integer[]) v.toArray(new Integer[v.size()]);
+ }
}
Modified: trunk/freenet/src/freenet/client/async/SplitFileFetcherSubSegment.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SplitFileFetcherSubSegment.java
2008-02-22 20:08:35 UTC (rev 18107)
+++ trunk/freenet/src/freenet/client/async/SplitFileFetcherSubSegment.java
2008-02-22 20:14:09 UTC (rev 18108)
@@ -84,8 +84,12 @@
return key;
}
- public synchronized Object[] allKeys() {
- return blockNums.toArray();
+ /**
+ * Fetch the array from the segment because we need to include *ALL*
keys, especially
+ * those on cooldown queues. This is important when unregistering.
+ */
+ public Object[] allKeys() {
+ return segment.getKeyNumbersAtRetryLevel(retryCount);
}
private synchronized Object removeRandomBlockNum() {