Author: toad
Date: 2008-10-29 20:25:37 +0000 (Wed, 29 Oct 2008)
New Revision: 23191

Added:
   branches/db4o/freenet/src/freenet/client/async/NoValidBlocksException.java
Modified:
   branches/db4o/freenet/src/freenet/client/async/ClientRequestScheduler.java
   branches/db4o/freenet/src/freenet/client/async/PersistentChosenRequest.java
Log:
PCR constructor: throw NoValidBlocksException if no valid blocks
Fix addToStarterQueue retval
Logging


Modified: 
branches/db4o/freenet/src/freenet/client/async/ClientRequestScheduler.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/ClientRequestScheduler.java  
2008-10-29 20:21:19 UTC (rev 23190)
+++ branches/db4o/freenet/src/freenet/client/async/ClientRequestScheduler.java  
2008-10-29 20:25:37 UTC (rev 23191)
@@ -586,7 +586,12 @@
                if(logMINOR)
                        Logger.minor(this, "Adding to starter queue: "+request);
                container.activate(request, 1);
-               PersistentChosenRequest chosen = new 
PersistentChosenRequest(request, request.getPriorityClass(container), 
request.getRetryCount(), container, ClientRequestScheduler.this, clientContext);
+               PersistentChosenRequest chosen;
+               try {
+                       chosen = new PersistentChosenRequest(request, 
request.getPriorityClass(container), request.getRetryCount(), container, 
ClientRequestScheduler.this, clientContext);
+               } catch (NoValidBlocksException e) {
+                       return false;
+               }
                if(logMINOR)
                        Logger.minor(this, "Created PCR: "+chosen);
                container.deactivate(request, 1);
@@ -606,7 +611,7 @@
                                runningPersistentRequests.add(request);
                                if(logMINOR)
                                        Logger.minor(this, "Added to running 
persistent requests, size now "+runningPersistentRequests.size()+" : "+request);
-                               return length < MAX_STARTER_QUEUE_SIZE;
+                               return length > MAX_STARTER_QUEUE_SIZE;
                        }
                }
                if(dumpNew)

Added: 
branches/db4o/freenet/src/freenet/client/async/NoValidBlocksException.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/NoValidBlocksException.java  
                        (rev 0)
+++ branches/db4o/freenet/src/freenet/client/async/NoValidBlocksException.java  
2008-10-29 20:25:37 UTC (rev 23191)
@@ -0,0 +1,5 @@
+package freenet.client.async;
+
+public class NoValidBlocksException extends Exception {
+
+}

Modified: 
branches/db4o/freenet/src/freenet/client/async/PersistentChosenRequest.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/PersistentChosenRequest.java 
2008-10-29 20:21:19 UTC (rev 23190)
+++ branches/db4o/freenet/src/freenet/client/async/PersistentChosenRequest.java 
2008-10-29 20:25:37 UTC (rev 23191)
@@ -49,7 +49,7 @@
        private boolean logMINOR;
        private boolean finished;

-       PersistentChosenRequest(SendableRequest req, short prio, int 
retryCount, ObjectContainer container, RequestScheduler sched, ClientContext 
context) {
+       PersistentChosenRequest(SendableRequest req, short prio, int 
retryCount, ObjectContainer container, RequestScheduler sched, ClientContext 
context) throws NoValidBlocksException {
                request = req;
                this.prio = prio;
                this.retryCount = retryCount;
@@ -75,6 +75,10 @@
                if(!reqActive)
                        container.activate(req, 1);
                List<PersistentChosenBlock> candidates = req.makeBlocks(this, 
sched, container, context);
+               if(candidates == null) {
+                       if(!reqActive) container.deactivate(req, 1);
+                       throw new NoValidBlocksException();
+               }
                for(PersistentChosenBlock block : candidates) {
                        Key key = block.key;
                        if(key != null && sched.hasFetchingKey(key))
@@ -90,7 +94,7 @@
        void onFinished(PersistentChosenBlock block, ClientContext context) {
                logMINOR = Logger.shouldLog(Logger.MINOR, this);
                if(logMINOR)
-                       Logger.minor(this, "onFinished() on "+this+" for 
"+block);
+                       Logger.minor(this, "onFinished() on "+this+" for 
"+block, new Exception("debug"));
                synchronized(this) {
                        // Remove by pointer
                        for(int i=0;i<blocksNotStarted.size();i++) {


Reply via email to