Author: toad
Date: 2009-02-14 13:29:47 +0000 (Sat, 14 Feb 2009)
New Revision: 25645

Modified:
   branches/db4o/freenet/src/freenet/client/async/ClientRequestScheduler.java
Log:
Don't continually fill the starter queue


Modified: 
branches/db4o/freenet/src/freenet/client/async/ClientRequestScheduler.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/ClientRequestScheduler.java  
2009-02-14 12:29:55 UTC (rev 25644)
+++ branches/db4o/freenet/src/freenet/client/async/ClientRequestScheduler.java  
2009-02-14 13:29:47 UTC (rev 25645)
@@ -570,7 +570,14 @@
                }
        }
        
+       /* If new stuff is added, maybeFillStarterQueue will be called anyway,
+        * so it is safe to not run the queue filler regularly. */
+       private long lastFilledStarterQueueEmpty = -1;
+       
        public void queueFillRequestStarterQueue() {
+               if(lastFilledStarterQueueEmpty > 0 &&
+                               System.currentTimeMillis() - 
lastFilledStarterQueueEmpty < 60*1000)
+                       return;
                if(starterQueueLength() > MAX_STARTER_QUEUE_SIZE / 2)
                        return;
                jobRunner.queue(requestStarterQueueFiller, 
NativeThread.MAX_PRIORITY, true);
@@ -664,7 +671,8 @@
                if(PRIORITY_SOFT.equals(choosenPriorityScheduler))
                        fuzz = -1;
                else if(PRIORITY_HARD.equals(choosenPriorityScheduler))
-                       fuzz = 0;       
+                       fuzz = 0;
+               boolean added = false;
                synchronized(starterQueue) {
                        if(logMINOR && (!isSSKScheduler) && 
(!isInsertScheduler)) {
                                Logger.minor(this, "Scheduling CHK fetches...");
@@ -715,7 +723,14 @@
                }
                while(true) {
                        SendableRequest request = 
schedCore.removeFirstInner(fuzz, random, offeredKeys, starter, schedTransient, 
false, true, Short.MAX_VALUE, Integer.MAX_VALUE, context, container);
-                       if(request == null) return;
+                       if(request == null) {
+                               synchronized(ClientRequestScheduler.this) {
+                                       if(!added) 
+                                               lastFilledStarterQueueEmpty = 
System.currentTimeMillis();
+                               }
+                               return;
+                       }
+                       added = true;
                        boolean full = addToStarterQueue(request, container);
                        container.deactivate(request, 1);
                        starter.wakeUp();

_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to