Author: toad
Date: 2008-04-22 22:50:53 +0000 (Tue, 22 Apr 2008)
New Revision: 19509

Modified:
   trunk/freenet/src/freenet/node/Node.java
Log:
Much simpler this way around.

Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java    2008-04-22 22:49:12 UTC (rev 
19508)
+++ trunk/freenet/src/freenet/node/Node.java    2008-04-22 22:50:53 UTC (rev 
19509)
@@ -2370,25 +2370,19 @@

        public boolean lockUID(long uid, boolean ssk, boolean insert, boolean 
offerReply, boolean local) {
                Long l = new Long(uid);
-               HashSet set = getUIDTracker(ssk, insert, offerReply, local);
-               synchronized(set) {
-                       if(logMINOR) Logger.minor(this, "Locking "+uid+" 
ssk="+ssk+" insert="+insert+" offerReply="+offerReply+" local="+local+" 
size="+set.size());
-                       if(!set.add(l)) {
+               synchronized(runningUIDs) {
+                       if(!runningUIDs.add(l)) {
                                // Already present.
                                return false;
                        }
-                       if(logMINOR) Logger.minor(this, "Locked "+uid+" 
ssk="+ssk+" insert="+insert+" offerReply="+offerReply+" local="+local+" 
size="+set.size());
                }
-               synchronized(runningUIDs) {
-                       if(runningUIDs.add(l)) {
-                               // Not already present, we are okay.
-                               return true;
-                       } // Else is already present, we need to return false 
*and remove it from the other set*
-               }
+               HashSet set = getUIDTracker(ssk, insert, offerReply, local);
                synchronized(set) {
-                       set.remove(l);
+                       if(logMINOR) Logger.minor(this, "Locking "+uid+" 
ssk="+ssk+" insert="+insert+" offerReply="+offerReply+" local="+local+" 
size="+set.size());
+                       set.add(l);
+                       if(logMINOR) Logger.minor(this, "Locked "+uid+" 
ssk="+ssk+" insert="+insert+" offerReply="+offerReply+" local="+local+" 
size="+set.size());
                }
-               return false;
+               return true;
        }

        public void unlockUID(long uid, boolean ssk, boolean insert, boolean 
canFail, boolean offerReply, boolean local) {


Reply via email to