Author: j16sdiz
Date: 2008-07-13 13:26:42 +0000 (Sun, 13 Jul 2008)
New Revision: 21130

Modified:
   
branches/saltedhashstore/freenet/src/freenet/store/saltedhash/SaltedHashFreenetStore.java
Log:
more consistent logic

Modified: 
branches/saltedhashstore/freenet/src/freenet/store/saltedhash/SaltedHashFreenetStore.java
===================================================================
--- 
branches/saltedhashstore/freenet/src/freenet/store/saltedhash/SaltedHashFreenetStore.java
   2008-07-12 23:41:37 UTC (rev 21129)
+++ 
branches/saltedhashstore/freenet/src/freenet/store/saltedhash/SaltedHashFreenetStore.java
   2008-07-13 13:26:42 UTC (rev 21130)
@@ -600,9 +600,10 @@
        }

        /**
-        * Read entry from disk.
+        * Read entry from disk. Before calling this function, you should 
acquire all required locks.
         * 
-        * Before calling this function, you should acquire all required locks.
+        * @return <code>null</code> if and only if <code>routingKey</code> is 
not <code>null</code> and
+        *         the key does not match the entry.
         */
        private Entry readEntry(long offset, byte[] routingKey, boolean 
withData) throws IOException {
                ByteBuffer mbf = ByteBuffer.allocate(Entry.METADATA_LENGTH);
@@ -617,10 +618,9 @@
                Entry entry = new Entry(mbf, null, null);
                entry.curOffset = offset;

-               if (entry.isFree())
-                       return entry; // don't read free entry
-
                if (routingKey != null) {
+                       if (entry.isFree())
+                               return null;
                        if 
(!Arrays.equals(cipherManager.getDigestedKey(routingKey), 
entry.digestedRoutingKey))
                                return null;



Reply via email to