Author: toad
Date: 2006-07-22 20:35:40 +0000 (Sat, 22 Jul 2006)
New Revision: 9721

Modified:
   trunk/freenet/src/freenet/node/ARKFetcher.java
   trunk/freenet/src/freenet/node/Node.java
Log:
more locking simplifications

Modified: trunk/freenet/src/freenet/node/ARKFetcher.java
===================================================================
--- trunk/freenet/src/freenet/node/ARKFetcher.java      2006-07-22 20:05:03 UTC 
(rev 9720)
+++ trunk/freenet/src/freenet/node/ARKFetcher.java      2006-07-22 20:35:40 UTC 
(rev 9721)
@@ -28,7 +28,7 @@
        private static final int MAX_BACKOFF = 60*60*1000;  // 1 hour
        private static final int MIN_BACKOFF = 5*1000;  // 5 seconds
        private int backoff = MIN_BACKOFF;
-       private String identity;
+       private final String identity;
        private boolean isFetching;
        private boolean started;
        private long startedEdition;
@@ -100,20 +100,16 @@

                if(cg != null)
                        try {
-                               boolean localIsFetching = false;
+                               boolean mustAdd = false;
                                synchronized(this) {
-                                       localIsFetching = isFetching;
-                               }
-                               if(!localIsFetching) {
-                                       String localIdentity = null;
-                                       synchronized(this) {
-                                               localIdentity = identity;
-                                       }
-                                       node.addARKFetcher(localIdentity,this);
-                                       synchronized(this) {
+                                       if(!isFetching) {
+                                               mustAdd = true;
                                                isFetching = true;
                                        }
                                }
+                               if(mustAdd) {
+                                       node.addARKFetcher(identity, this);
+                               }

                                cg.start();
                        } catch (FetchException e) {

Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java    2006-07-22 20:05:03 UTC (rev 
9720)
+++ trunk/freenet/src/freenet/node/Node.java    2006-07-22 20:35:40 UTC (rev 
9721)
@@ -3332,7 +3332,10 @@
                synchronized(arkFetchers) {
                        if(arkFetchers.containsKey(identity)) {
                                ARKFetcher af = (ARKFetcher) 
arkFetchers.get(identity);
-                               Logger.error(this, "addARKFetcher(): identity 
'"+identity+"' already in arkFetcher as "+af+" and you want to add"+fetcher);
+                               if(af != fetcher)
+                                       Logger.error(this, "addARKFetcher(): 
identity '"+identity+"' already in arkFetcher as "+af+" and you want to 
add"+fetcher);
+                               else
+                                       Logger.minor(this, "Re-adding 
"+identity+" : "+fetcher);
                                return;
                        }
                        Logger.minor(this, "addARKFetcher(): adding ARK Fetcher 
for "+identity);


Reply via email to