Author: toad
Date: 2009-02-12 16:17:43 +0000 (Thu, 12 Feb 2009)
New Revision: 25598

Modified:
   
branches/db4o/freenet/src/freenet/client/async/ClientRequestSchedulerCore.java
   branches/db4o/freenet/src/freenet/node/Node.java
   branches/db4o/freenet/src/freenet/support/RandomGrabArray.java
   branches/db4o/freenet/src/freenet/support/RemoveRandomWithObject.java
   branches/db4o/freenet/src/freenet/support/SectoredRandomGrabArray.java
   
branches/db4o/freenet/src/freenet/support/SectoredRandomGrabArrayWithObject.java
Log:
Hopefully fix leak


Modified: 
branches/db4o/freenet/src/freenet/client/async/ClientRequestSchedulerCore.java
===================================================================
--- 
branches/db4o/freenet/src/freenet/client/async/ClientRequestSchedulerCore.java  
    2009-02-12 14:35:21 UTC (rev 25597)
+++ 
branches/db4o/freenet/src/freenet/client/async/ClientRequestSchedulerCore.java  
    2009-02-12 16:17:43 UTC (rev 25598)
@@ -447,6 +447,8 @@
                        SendableRequest req = (SendableRequest) 
chosenTracker.removeRandom(starter, container, context);
                        if(chosenTracker.isEmpty()) {
                                trackerParent.remove(chosenTracker.getNumber(), 
container);
+                               if(chosenTracker.persistent())
+                                       chosenTracker.removeFrom(container);
                                if(trackerParent.isEmpty()) {
                                        if(logMINOR) Logger.minor(this, "Should 
remove priority");
                                }

Modified: branches/db4o/freenet/src/freenet/node/Node.java
===================================================================
--- branches/db4o/freenet/src/freenet/node/Node.java    2009-02-12 14:35:21 UTC 
(rev 25597)
+++ branches/db4o/freenet/src/freenet/node/Node.java    2009-02-12 16:17:43 UTC 
(rev 25598)
@@ -22,6 +22,7 @@
 import java.util.MissingResourceException;
 import java.util.Random;
 import java.util.Set;
+import java.util.TreeMap;
 import java.util.Vector;
 
 import org.spaceroots.mantissa.random.MersenneTwister;
@@ -30,6 +31,7 @@
 import com.db4o.Db4o;
 import com.db4o.ObjectContainer;
 import com.db4o.ObjectServer;
+import com.db4o.ObjectSet;
 import com.db4o.config.Configuration;
 import com.db4o.config.QueryEvaluationMode;
 import com.db4o.diagnostic.ClassHasNoFields;
@@ -893,6 +895,25 @@
                db = Db4o.openFile(dbConfig, new File(nodeDir, 
"node.db4o").toString());
                
                System.err.println("Opened database");
+               
+               // DUMP DATABASE CONTENTS
+               System.err.println("DUMPING DATABASE CONTENTS:");
+               ObjectSet<Object> contents = db.queryByExample(new Object());
+               Map<String,Integer> map = new HashMap<String, Integer>();
+               for(Object o : contents) {
+                       String name = o.getClass().getName();
+                       if((map.get(name)) != null) {
+                               map.put(name, map.get(name)+1);
+                       } else {
+                               map.put(name, 1);
+                       }
+               }
+               int total = 0;
+               for(Map.Entry<String,Integer> entry : map.entrySet()) {
+                       System.err.println(entry.getKey()+" : 
"+entry.getValue());
+                       total += entry.getValue();
+               }
+               System.err.println("END DATABASE DUMP: "+total+" objects");
 
                // Boot ID
                bootID = random.nextLong();

Modified: branches/db4o/freenet/src/freenet/support/RandomGrabArray.java
===================================================================
--- branches/db4o/freenet/src/freenet/support/RandomGrabArray.java      
2009-02-12 14:35:21 UTC (rev 25597)
+++ branches/db4o/freenet/src/freenet/support/RandomGrabArray.java      
2009-02-12 16:17:43 UTC (rev 25598)
@@ -478,4 +478,20 @@
                        container.deactivate(blocks[blockNo], 1);
                return item;
        }
+       
+
+       public void removeFrom(ObjectContainer container) {
+               if(blocks != null) {
+                       for(Block block : blocks) {
+                               for(RandomGrabArrayItem item : block.reqs) {
+                                       if(item != null) {
+                                               Logger.error(this, "VALID ITEM 
WHILE DELETING BLOCK: "+item+" on "+this);
+                                               return;
+                                       }
+                               }
+                               container.delete(block);
+                       }
+               }
+               container.delete(this);
+       }
 }

Modified: branches/db4o/freenet/src/freenet/support/RemoveRandomWithObject.java
===================================================================
--- branches/db4o/freenet/src/freenet/support/RemoveRandomWithObject.java       
2009-02-12 14:35:21 UTC (rev 25597)
+++ branches/db4o/freenet/src/freenet/support/RemoveRandomWithObject.java       
2009-02-12 16:17:43 UTC (rev 25598)
@@ -1,9 +1,13 @@
 package freenet.support;
 
+import com.db4o.ObjectContainer;
+
 public interface RemoveRandomWithObject extends RemoveRandom {
 
        public Object getObject();
 
        public boolean isEmpty();
+
+       public void removeFrom(ObjectContainer container);
        
 }

Modified: branches/db4o/freenet/src/freenet/support/SectoredRandomGrabArray.java
===================================================================
--- branches/db4o/freenet/src/freenet/support/SectoredRandomGrabArray.java      
2009-02-12 14:35:21 UTC (rev 25597)
+++ branches/db4o/freenet/src/freenet/support/SectoredRandomGrabArray.java      
2009-02-12 16:17:43 UTC (rev 25598)
@@ -136,8 +136,10 @@
                                                Logger.minor(this, "Removing 
only grab array (0) : "+rga);
                                        grabArrays = new 
RemoveRandomWithObject[0];
                                        grabClients = new Object[0];
-                                       if(persistent)
+                                       if(persistent) {
                                                container.store(this);
+                                               rga.removeFrom(container);
+                                       }
                                }
                                if(logMINOR)
                                        Logger.minor(this, "Returning (one item 
only) "+item+" for "+rga);
@@ -174,16 +176,21 @@
                                        if(firstRGA.isEmpty() && rga.isEmpty()) 
{
                                                grabArrays = new 
RemoveRandomWithObject[0];
                                                grabClients = new Object[0];
-                                               if(persistent)
+                                               if(persistent) {
                                                        container.store(this);
+                                                       
firstRGA.removeFrom(container);
+                                                       
rga.removeFrom(container);
+                                               }
                                        } else if(firstRGA.isEmpty()) {
                                                if(persistent) {
                                                        
container.activate(firstRGA, 1);
                                                }
                                                grabArrays = new 
RemoveRandomWithObject[] { rga };
                                                grabClients = new Object[] { 
grabClients[x] };
-                                               if(persistent)
+                                               if(persistent) {
                                                        container.store(this);
+                                                       
firstRGA.removeFrom(container);
+                                               }
                                        }
                                        if(persistent) {
                                                container.deactivate(rga, 1);
@@ -217,8 +224,10 @@
                                if(logMINOR)
                                        Logger.minor(this, "Removing grab array 
"+x+" : "+rga+" (is empty)");
                                removeElement(x);
-                               if(persistent)
+                               if(persistent) {
                                        container.store(this);
+                                       rga.removeFrom(container);
+                               }
                        }
                        if(item == null) {
                                if(!rga.isEmpty()) {
@@ -271,5 +280,17 @@
        public int size() {
                return grabArrays.length;
        }
+       
+       public void removeFrom(ObjectContainer container) {
+               if(grabArrays != null && grabArrays.length != 0) {
+                       for(RemoveRandomWithObject rr : grabArrays) {
+                               if(rr != null) {
+                                       Logger.error(this, "NOT EMPTY REMOVING 
"+this+" : "+rr);
+                                       return;
+                               }
+                       }
+               }
+               container.delete(this);
+       }
 
 }

Modified: 
branches/db4o/freenet/src/freenet/support/SectoredRandomGrabArrayWithObject.java
===================================================================
--- 
branches/db4o/freenet/src/freenet/support/SectoredRandomGrabArrayWithObject.java
    2009-02-12 14:35:21 UTC (rev 25597)
+++ 
branches/db4o/freenet/src/freenet/support/SectoredRandomGrabArrayWithObject.java
    2009-02-12 16:17:43 UTC (rev 25598)
@@ -19,5 +19,5 @@
        public String toString() {
                return super.toString()+":"+object;
        }
-       
+
 }

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

Reply via email to