Author: toad
Date: 2007-03-24 20:13:01 +0000 (Sat, 24 Mar 2007)
New Revision: 12340

Modified:
   trunk/freenet/src/freenet/node/NodeDispatcher.java
Log:
Check for loop before checking for overload

Modified: trunk/freenet/src/freenet/node/NodeDispatcher.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeDispatcher.java  2007-03-24 20:08:06 UTC 
(rev 12339)
+++ trunk/freenet/src/freenet/node/NodeDispatcher.java  2007-03-24 20:13:01 UTC 
(rev 12340)
@@ -142,6 +142,18 @@
                        }
                        return true;
                }
+               if(!node.lockUID(id)) {
+                       if(logMINOR) Logger.minor(this, "Could not lock ID 
"+id+" -> rejecting (already running)");
+                       Message rejected = DMT.createFNPRejectedLoop(id);
+                       try {
+                               ((PeerNode)(m.getSource())).sendAsync(rejected, 
null, 0, null);
+                       } catch (NotConnectedException e) {
+                               Logger.normal(this, "Rejecting insert request 
from "+m.getSource().getPeer()+": "+e);
+                       }
+                       return true;
+               } else {
+                       if(logMINOR) Logger.minor(this, "Locked "+id);
+               }
                String rejectReason = nodeStats.shouldRejectRequest(!isSSK, 
false, isSSK);
                if(rejectReason != null) {
                        // can accept 1 CHK request every so often, but not 
with SSKs because they aren't throttled so won't sort out bwlimitDelayTime, 
which was the whole reason for accepting them when overloaded...
@@ -152,21 +164,10 @@
                        } catch (NotConnectedException e) {
                                Logger.normal(this, "Rejecting (overload) data 
request from "+m.getSource().getPeer()+": "+e);
                        }
+                       node.unlockUID(id);
                        node.completed(id);
                        return true;
                }
-               if(!node.lockUID(id)) {
-                       if(logMINOR) Logger.minor(this, "Could not lock ID 
"+id+" -> rejecting (already running)");
-                       Message rejected = DMT.createFNPRejectedLoop(id);
-                       try {
-                               ((PeerNode)(m.getSource())).sendAsync(rejected, 
null, 0, null);
-                       } catch (NotConnectedException e) {
-                               Logger.normal(this, "Rejecting insert request 
from "+m.getSource().getPeer()+": "+e);
-                       }
-                       return true;
-               } else {
-                       if(logMINOR) Logger.minor(this, "Locked "+id);
-               }
                //if(!node.lockUID(id)) return false;
                RequestHandler rh = new RequestHandler(m, id, node);
                Thread t = new Thread(rh, "RequestHandler for UID "+id);


Reply via email to