Author: toad
Date: 2007-05-02 21:53:28 +0000 (Wed, 02 May 2007)
New Revision: 13113
Modified:
trunk/freenet/src/freenet/support/RandomGrabArray.java
trunk/freenet/src/freenet/support/SectoredRandomGrabArray.java
Log:
Maybe fix downloads
Modified: trunk/freenet/src/freenet/support/RandomGrabArray.java
===================================================================
--- trunk/freenet/src/freenet/support/RandomGrabArray.java 2007-05-02
21:02:17 UTC (rev 13112)
+++ trunk/freenet/src/freenet/support/RandomGrabArray.java 2007-05-02
21:53:28 UTC (rev 13113)
@@ -63,6 +63,7 @@
}
int i = rand.nextInt(index);
ret = reqs[i];
+ if(ret.isCancelled()) ret = null;
if(ret != null && !ret.canRemove()) {
ret.setParentGrabArray(null);
return ret;
Modified: trunk/freenet/src/freenet/support/SectoredRandomGrabArray.java
===================================================================
--- trunk/freenet/src/freenet/support/SectoredRandomGrabArray.java
2007-05-02 21:02:17 UTC (rev 13112)
+++ trunk/freenet/src/freenet/support/SectoredRandomGrabArray.java
2007-05-02 21:53:28 UTC (rev 13113)
@@ -74,7 +74,10 @@
if(logMINOR)
Logger.minor(this, "RGA has picked
"+x+"/"+grabArrays.length+": "+item+
(item==null ? "" : ("
cancelled="+item.isCancelled()+")"))+" rga.isEmpty="+rga.isEmpty());
- if(rga.isEmpty() || (item == null) ||
item.isCancelled()) {
+ // Just because the item is cancelled does not
necessarily mean the whole client is.
+ // E.g. a segment may return cancelled because it is
decoding, that doesn't mean
+ // other segements are cancelled. So just go around the
loop in that case.
+ if(rga.isEmpty() || (item == null)) {
if(logMINOR)
Logger.minor(this, "Removing grab array
"+x+" : "+rga+" for "+rga.getClient()+" (is empty)");
Object client = rga.getClient();