Author: toad
Date: 2008-02-07 00:05:31 +0000 (Thu, 07 Feb 2008)
New Revision: 17632

Modified:
   trunk/freenet/src/freenet/node/Node.java
Log:
Commit the pubkey before the data, otherwise we get a race condition and end up 
deleting the data.

Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java    2008-02-06 23:58:35 UTC (rev 
17631)
+++ trunk/freenet/src/freenet/node/Node.java    2008-02-07 00:05:31 UTC (rev 
17632)
@@ -2079,11 +2079,13 @@

        public void store(SSKBlock block, boolean deep) throws 
KeyCollisionException {
                try {
+                       // Store the pubkey before storing the data, otherwise 
we can get a race condition and
+                       // end up deleting the SSK data.
+                       cacheKey(((NodeSSK)block.getKey()).getPubKeyHash(), 
((NodeSSK)block.getKey()).getPubKey(), deep);
                        if(deep) {
                                sskDatastore.put(block, false);
                        }
                        sskDatacache.put(block, false);
-                       cacheKey(((NodeSSK)block.getKey()).getPubKeyHash(), 
((NodeSSK)block.getKey()).getPubKey(), deep);
                        if(clientCore != null && clientCore.requestStarters != 
null)
                                
clientCore.requestStarters.sskFetchScheduler.tripPendingKey(block);
                        failureTable.onFound(block);


Reply via email to