Author: robert
Date: 2007-12-10 20:06:31 +0000 (Mon, 10 Dec 2007)
New Revision: 16455

Modified:
   trunk/freenet/src/freenet/node/RequestHandler.java
Log:
clean up error checks


Modified: trunk/freenet/src/freenet/node/RequestHandler.java
===================================================================
--- trunk/freenet/src/freenet/node/RequestHandler.java  2007-12-10 20:05:30 UTC 
(rev 16454)
+++ trunk/freenet/src/freenet/node/RequestHandler.java  2007-12-10 20:06:31 UTC 
(rev 16455)
@@ -43,7 +43,8 @@
     /** The RequestSender, if any */
     private RequestSender rs;
     private int status;
-    
+       private boolean appliedByteCounts=false;
+       
     public String toString() {
         return super.toString()+" for "+uid;
     }
@@ -72,14 +73,12 @@

     public void run() {
            freenet.support.Logger.OSThread.logPID(this);
-       boolean thrown = false;
         try {
                realRun();
         } catch (NotConnectedException e) {
                // Ignore, normal
         } catch (Throwable t) {
             Logger.error(this, "Caught "+t, t);
-            thrown = true;
         } finally {
                node.removeTransferringRequestHandler(uid);
             node.unlockUID(uid, key instanceof NodeSSK, false, false);
@@ -87,6 +86,11 @@
     }

     private void applyByteCounts() {
+               if (appliedByteCounts) {
+                       Logger.error(this, "applyByteCounts already called", 
new Exception("error"));
+                       return;
+               }
+               appliedByteCounts=true;
         if((!finalTransferFailed) && rs != null && status != 
RequestSender.TIMED_OUT && status != RequestSender.GENERATED_REJECTED_OVERLOAD 
            && status != RequestSender.INTERNAL_ERROR) {
                int sent, rcvd;
@@ -306,15 +310,9 @@
                        Logger.error(this, "Error sending terminal message?! 
for " + RequestHandler.this);
                }

-        private boolean once=true;
                public void sent() {
-            //For byte counting, this relies on the fact that the callback 
will only be excuted once. This check might be paranoid.
-            if (once) {
-                applyByteCounts();
-                               once=false;
-            } else {
-                Logger.error(this, "terminalMessage sent multiple times? for " 
+ RequestHandler.this);
-            }
+            //For byte counting, this relies on the fact that the callback 
will only be excuted once.
+                       applyByteCounts();
         }
        }



Reply via email to