Author: toad
Date: 2008-10-23 17:43:53 +0000 (Thu, 23 Oct 2008)
New Revision: 23053

Modified:
   branches/db4o/freenet/src/freenet/client/FECQueue.java
Log:
Deactivate jobs that won't be run immediately.


Modified: branches/db4o/freenet/src/freenet/client/FECQueue.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/FECQueue.java      2008-10-23 
17:43:30 UTC (rev 23052)
+++ branches/db4o/freenet/src/freenet/client/FECQueue.java      2008-10-23 
17:43:53 UTC (rev 23053)
@@ -101,9 +101,12 @@
                        job.activateForExecution(container);
                        container.store(job);
                }
+               boolean kept = false;
+               
                synchronized(this) {
                        if(!job.persistent) {
                                transientQueue[job.priority].addLast(job);
+                               kept = true;
                        } else {
                                int totalAbove = 0;
                                for(int i=0;i<job.priority;i++) {
@@ -120,6 +123,7 @@
                                                        Logger.minor(this, "Not 
adding persistent job to in-RAM cache, too many at same priority");
                                        } else {
                                                
persistentQueueCache[job.priority].addLast(job);
+                                               kept = true;
                                                int total = totalAbove + 
persistentQueueCache[job.priority].size();
                                                for(int 
i=job.priority+1;i<priorities;i++) {
                                                        total += 
persistentQueueCache[i].size();
@@ -133,6 +137,9 @@
                                        }
                                }
                        }
+                       if(!kept) {
+                               job.deactivate(container);
+                       }
                        if(runningFECThreads < maxThreads) {
                                executor.execute(runner, "FEC Pool 
"+fecPoolCounter++);
                                runningFECThreads++;


Reply via email to