Author: toad
Date: 2008-06-20 22:40:10 +0000 (Fri, 20 Jun 2008)
New Revision: 20542

Modified:
   branches/db4o/freenet/src/freenet/node/SendableRequest.java
   branches/db4o/freenet/src/freenet/support/RandomGrabArray.java
   branches/db4o/freenet/src/freenet/support/RandomGrabArrayItem.java
Log:
Store to the database when we change parent.

Modified: branches/db4o/freenet/src/freenet/node/SendableRequest.java
===================================================================
--- branches/db4o/freenet/src/freenet/node/SendableRequest.java 2008-06-20 
22:26:52 UTC (rev 20541)
+++ branches/db4o/freenet/src/freenet/node/SendableRequest.java 2008-06-20 
22:40:10 UTC (rev 20542)
@@ -76,8 +76,9 @@
                return true;
        }

-       public synchronized void setParentGrabArray(RandomGrabArray parent) {
+       public synchronized void setParentGrabArray(RandomGrabArray parent, 
ObjectContainer container) {
                parentGrabArray = parent;
+               container.set(this);
        }

        public void unregister(boolean staySubscribed, ObjectContainer 
container) {

Modified: branches/db4o/freenet/src/freenet/support/RandomGrabArray.java
===================================================================
--- branches/db4o/freenet/src/freenet/support/RandomGrabArray.java      
2008-06-20 22:26:52 UTC (rev 20541)
+++ branches/db4o/freenet/src/freenet/support/RandomGrabArray.java      
2008-06-20 22:40:10 UTC (rev 20542)
@@ -45,7 +45,7 @@
                        if(logMINOR) Logger.minor(this, "Is finished already: 
"+req);
                        return;
                }
-               req.setParentGrabArray(this);
+               req.setParentGrabArray(this, container);
                synchronized(this) {
                        if(contents.contains(req)) {
                                if(logMINOR) Logger.minor(this, "Already 
contains "+req+" : "+this+" size now "+index);
@@ -123,7 +123,7 @@
                                                                        
reqs[chosenIndex] = reqs[index-1];
                                                                }
                                                                index--;
-                                                               
ret.setParentGrabArray(null);
+                                                               
ret.setParentGrabArray(null, container);
                                                        }
                                                        if(logMINOR) 
Logger.minor(this, "Chosen random item "+ret+" out of "+valid);
                                                        if(persistent && 
changedMe)
@@ -150,7 +150,7 @@
                                                                }
                                                                index--;
                                                                if(logMINOR) 
Logger.minor(this, "No valid or excluded items after removing "+ret);
-                                                               
ret.setParentGrabArray(null);
+                                                               
ret.setParentGrabArray(null, container);
                                                        } else {
                                                                if(logMINOR) 
Logger.minor(this, "No valid or excluded items apart from "+ret);
                                                        }
@@ -217,7 +217,7 @@
                        }
                }
                if(logMINOR) Logger.minor(this, "Returning "+ret+" of "+index);
-               ret.setParentGrabArray(null);
+               ret.setParentGrabArray(null, container);
                if(persistent)
                        container.set(this);
                return ret;
@@ -236,7 +236,7 @@
                                }
                        }
                }
-               it.setParentGrabArray(null);
+               it.setParentGrabArray(null, container);
                if(persistent)
                        container.set(this);
        }

Modified: branches/db4o/freenet/src/freenet/support/RandomGrabArrayItem.java
===================================================================
--- branches/db4o/freenet/src/freenet/support/RandomGrabArrayItem.java  
2008-06-20 22:26:52 UTC (rev 20541)
+++ branches/db4o/freenet/src/freenet/support/RandomGrabArrayItem.java  
2008-06-20 22:40:10 UTC (rev 20542)
@@ -1,5 +1,7 @@
 package freenet.support;

+import com.db4o.ObjectContainer;
+
 public interface RandomGrabArrayItem {

        /** If true, will be automatically removed from the RGA, and not 
returned.
@@ -23,7 +25,7 @@
        public boolean knowsParentGrabArray();

        /** Notify the item that it has been registered on a specific 
RandomGrabArray */
-       public void setParentGrabArray(RandomGrabArray parent);
+       public void setParentGrabArray(RandomGrabArray parent, ObjectContainer 
container);

        /** If the item remembers its parent RandomGrabArray, return it */
        public RandomGrabArray getParentGrabArray();


Reply via email to