Author: toad
Date: 2008-03-21 17:16:24 +0000 (Fri, 21 Mar 2008)
New Revision: 18677

Modified:
   trunk/freenet/src/freenet/client/async/BaseSingleFileFetcher.java
   trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
   trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
   trunk/freenet/src/freenet/client/async/SplitFileFetcherSubSegment.java
   trunk/freenet/src/freenet/node/SendableGet.java
Log:
Don't requeue after cooldown until the deadline has passed.
If we have several requestors queued for a single key, this can happen.

Modified: trunk/freenet/src/freenet/client/async/BaseSingleFileFetcher.java
===================================================================
--- trunk/freenet/src/freenet/client/async/BaseSingleFileFetcher.java   
2008-03-21 16:05:21 UTC (rev 18676)
+++ trunk/freenet/src/freenet/client/async/BaseSingleFileFetcher.java   
2008-03-21 17:16:24 UTC (rev 18677)
@@ -147,7 +147,11 @@
                return cooldownWakeupTime;
        }

-       public void requeueAfterCooldown(Key key) {
+       public void requeueAfterCooldown(Key key, long time) {
+               if(cooldownWakeupTime > time) {
+                       if(Logger.shouldLog(Logger.MINOR, this)) 
Logger.minor(this, "Not requeueing as deadline has not passed yet");
+                       return;
+               }
                if(!(key.equals(this.key.getNodeKey()))) {
                        Logger.error(this, "Got requeueAfterCooldown for wrong 
key: "+key+" but mine is "+this.key.getNodeKey()+" for "+this.key);
                        return;

Modified: trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
===================================================================
--- trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java  
2008-03-21 16:05:21 UTC (rev 18676)
+++ trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java  
2008-03-21 17:16:24 UTC (rev 18677)
@@ -693,11 +693,11 @@
                                continue;
                        } else if(o instanceof SendableGet) {
                                SendableGet get = (SendableGet) o;
-                               get.requeueAfterCooldown(key);
+                               get.requeueAfterCooldown(key, now);
                        } else {
                                SendableGet[] gets = (SendableGet[]) o;
                                for(int i=0;i<gets.length;i++)
-                                       gets[i].requeueAfterCooldown(key);
+                                       gets[i].requeueAfterCooldown(key, now);
                        }
                }
        }

Modified: trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java 
2008-03-21 16:05:21 UTC (rev 18676)
+++ trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java 
2008-03-21 17:16:24 UTC (rev 18677)
@@ -562,7 +562,7 @@
                        return checkCooldownTimes[blockNum - dataKeys.length];
        }

-       public void requeueAfterCooldown(Key key) {
+       public void requeueAfterCooldown(Key key, long time) {
                if(isFinishing()) return;
                boolean notFound = true;
                int maxTries = blockFetchContext.maxNonSplitfileRetries;
@@ -570,6 +570,11 @@
                for(int i=0;i<dataKeys.length;i++) {
                        if(dataKeys[i] == null) continue;
                        if(dataKeys[i].getNodeKey().equals(key)) {
+                               if(dataCooldownTimes[i] > time) {
+                                       if(logMINOR)
+                                               Logger.minor(this, "Not 
retrying after cooldown for data block "+i+"as deadline has not passed yet on 
"+this);
+                                       return;
+                               }
                                int tries = dataRetries[i];
                                SplitFileFetcherSubSegment sub = 
getSubSegment(tries);
                                if(logMINOR)
@@ -581,6 +586,11 @@
                for(int i=0;i<checkKeys.length;i++) {
                        if(checkKeys[i] == null) continue;
                        if(checkKeys[i].getNodeKey().equals(key)) {
+                               if(checkCooldownTimes[i] > time) {
+                                       if(logMINOR)
+                                               Logger.minor(this, "Not 
retrying after cooldown for data block "+i+" as deadline has not passed yet on 
"+this);
+                                       return;
+                               }
                                int tries = checkRetries[i];
                                SplitFileFetcherSubSegment sub = 
getSubSegment(tries);
                                if(logMINOR)

Modified: trunk/freenet/src/freenet/client/async/SplitFileFetcherSubSegment.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SplitFileFetcherSubSegment.java      
2008-03-21 16:05:21 UTC (rev 18676)
+++ trunk/freenet/src/freenet/client/async/SplitFileFetcherSubSegment.java      
2008-03-21 17:16:24 UTC (rev 18677)
@@ -383,10 +383,10 @@
                return segment.getCooldownWakeup(((Integer)token).intValue());
        }

-       public void requeueAfterCooldown(Key key) {
+       public void requeueAfterCooldown(Key key, long time) {
                if(Logger.shouldLog(Logger.MINOR, this))
                        Logger.minor(this, "Requeueing after cooldown "+key+" 
for "+this);
-               segment.requeueAfterCooldown(key);
+               segment.requeueAfterCooldown(key, time);
        }

        public long getCooldownWakeupByKey(Key key) {

Modified: trunk/freenet/src/freenet/node/SendableGet.java
===================================================================
--- trunk/freenet/src/freenet/node/SendableGet.java     2008-03-21 16:05:21 UTC 
(rev 18676)
+++ trunk/freenet/src/freenet/node/SendableGet.java     2008-03-21 17:16:24 UTC 
(rev 18677)
@@ -135,8 +135,9 @@

        /**
         * Requeue a key after it has been on the cooldown queue for a while.
+        * Only requeue if our requeue time is less than or equal to the given 
time.
         * @param key
         */
-       public abstract void requeueAfterCooldown(Key key);
+       public abstract void requeueAfterCooldown(Key key, long time);

 }


Reply via email to