Author: toad
Date: 2008-04-22 22:47:35 +0000 (Tue, 22 Apr 2008)
New Revision: 19507

Modified:
   trunk/freenet/src/freenet/node/Node.java
Log:
Fix UID counter leak whenever we started a request in one category and got a 
loop in another.

Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java    2008-04-22 22:45:17 UTC (rev 
19506)
+++ trunk/freenet/src/freenet/node/Node.java    2008-04-22 22:47:35 UTC (rev 
19507)
@@ -2373,14 +2373,21 @@
                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.contains(l))
+                               return false;
                        set.add(l);
                        if(logMINOR) Logger.minor(this, "Locked "+uid+" 
ssk="+ssk+" insert="+insert+" offerReply="+offerReply+" local="+local+" 
size="+set.size());
                }
                synchronized(runningUIDs) {
-                       if(runningUIDs.contains(l)) return false;
-                       runningUIDs.add(l);
-                       return true;
+                       if(!runningUIDs.contains(l)) {
+                               runningUIDs.add(l);
+                               return true;
+                       }
                }
+               synchronized(set) {
+                       set.remove(l);
+               }
+               return false;
        }

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


Reply via email to