Author: toad
Date: 2009-04-03 14:35:29 +0000 (Fri, 03 Apr 2009)
New Revision: 26445

Modified:
   trunk/freenet/src/freenet/client/async/PersistentChosenRequest.java
Log:
More onDumped()


Modified: trunk/freenet/src/freenet/client/async/PersistentChosenRequest.java
===================================================================
--- trunk/freenet/src/freenet/client/async/PersistentChosenRequest.java 
2009-04-03 14:32:03 UTC (rev 26444)
+++ trunk/freenet/src/freenet/client/async/PersistentChosenRequest.java 
2009-04-03 14:35:29 UTC (rev 26445)
@@ -233,7 +233,10 @@
                        container.deactivate(request, 1);
        }
 
-       public synchronized ChosenBlock grabNotStarted(Random random, 
RequestScheduler sched) {
+       public ChosenBlock grabNotStarted(Random random, RequestScheduler 
sched) {
+               ArrayList<PersistentChosenBlock> dumped = null;
+               try {
+               synchronized(this) {
                while(true) {
                        int size = blocksNotStarted.size();
                        if(size == 0) return null;
@@ -241,12 +244,22 @@
                        if(size == 1) ret = blocksNotStarted.remove(0);
                        else ret = 
blocksNotStarted.remove(random.nextInt(size));
                        Key key = ret.key;
-                       if(key != null && sched.hasFetchingKey(key))
+                       if(key != null && sched.hasFetchingKey(key)) {
                                // Already fetching; remove from list.
+                               if(dumped == null) dumped = new 
ArrayList<PersistentChosenBlock>();
+                               dumped.add(ret);
                                continue;
+                       }
                        blocksStarted.add(ret);
                        return ret;
                }
+               }
+               } finally {
+               if(dumped != null) {
+                       for(PersistentChosenBlock block : dumped)
+                               block.onDumped();
+               }
+               }
        }
 
        public synchronized int sizeNotStarted() {

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

Reply via email to