Author: j16sdiz
Date: 2008-09-24 15:11:18 +0000 (Wed, 24 Sep 2008)
New Revision: 22797

Modified:
   trunk/freenet/src/freenet/store/saltedhash/SaltedHashFreenetStore.java
Log:
doh!!

Modified: trunk/freenet/src/freenet/store/saltedhash/SaltedHashFreenetStore.java
===================================================================
--- trunk/freenet/src/freenet/store/saltedhash/SaltedHashFreenetStore.java      
2008-09-24 15:05:04 UTC (rev 22796)
+++ trunk/freenet/src/freenet/store/saltedhash/SaltedHashFreenetStore.java      
2008-09-24 15:11:18 UTC (rev 22797)
@@ -178,9 +178,18 @@
                if (logMINOR)
                        Logger.minor(this, "Fetch " + 
HexUtil.bytesToHex(routingKey) + " for " + callback);

-               if (!configLock.readLock().tryLock(10000, 
TimeUnit.MILLISECONDS))
-                       return null;
                try {
+                       int retry = 0;
+                       while (!configLock.readLock().tryLock(2, 
TimeUnit.SECONDS)) {
+                               if (shutdown)
+                                       return null;
+                               if (retry++ > 10)
+                                       throw new IOException("lock timeout 
(20s)");
+                       }
+               } catch(InterruptedException e) {
+                       throw new IOException("interrupted: " +e);
+               }
+               try {
                        Map<Long, Condition> lockMap = lockPlainKey(routingKey, 
true);
                        if (lockMap == null) {
                                if (logDEBUG)
@@ -266,9 +275,18 @@
                if (logMINOR)
                        Logger.minor(this, "Putting " + 
HexUtil.bytesToHex(routingKey) + " (" + name + ")");

-               if (!configLock.readLock().tryLock(10000, 
TimeUnit.MILLISECONDS))
-                       throw new IOException("can't lock in 10 seconds");
                try {
+                       int retry = 0;
+                       while (!configLock.readLock().tryLock(2, 
TimeUnit.SECONDS)) {
+                               if (shutdown)
+                                       return;
+                               if (retry++ > 10)
+                                       throw new IOException("lock timeout 
(20s)");
+                       }
+               } catch(InterruptedException e) {
+                       throw new IOException("interrupted: " +e);
+               }
+               try {
                        Map<Long, Condition> lockMap = lockPlainKey(routingKey, 
false);
                        if (lockMap == null) {
                                if (logDEBUG)


Reply via email to