Update of /cvsroot/freenet/freenet/src/freenet/node/states/request
In directory sc8-pr-cvs1:/tmp/cvs-serv15465/src/freenet/node/states/request

Modified Files:
        Pending.java 
Log Message:
6173: Add a timeout for sending DataRequests of 1 hop time. If sending a message fails 
it counts as searchFailed, not as connectFailed (maybe we want an extra category? 
searchFailed seems reasonable for now though). NPE paranoia, logging.


Index: Pending.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/states/request/Pending.java,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- Pending.java        5 Sep 2003 16:08:51 -0000       1.54
+++ Pending.java        5 Sep 2003 17:10:34 -0000       1.55
@@ -586,6 +586,8 @@
                if(logDEBUG) Core.logger.log(this, "Sending message "+r+" on "
                                             +ch+" for "+this, Logger.DEBUG);
                outwardSender = new SendFinished(n, id, r.toString());
+               n.schedule(Core.hopTime(1), outwardSender);
+               // We only wait 1 hop time for accepted. Sending should take much less 
time.
                ch.sendMessageAsync(r, outwardSender);
                if(logDEBUG) Core.logger.log(this, "Sent message "+r+" on "+ch
                                             +" for "+this, Logger.DEBUG);
@@ -623,8 +625,7 @@
     
     public void receivedSendFinished(Node n, SendFinished sf) 
        throws BadStateException, RequestAbortException, EndOfRouteException {
-       if(!sf.finished())
-           throw new BadStateException("Got a SendFinished that wasn't finished: 
"+sf);
+       // If not finished, timed out
        if(sf == feedbackSender) {
            n.logger.log(this, "Got a SendFinished "+sf+" for "+this,
                         Logger.NORMAL /* FIXME! */ );
@@ -651,21 +652,23 @@
            // Our DataRequest send
            if(!sf.getSuccess()) {
                Exception e = sf.failCause();
-               if(e instanceof CommunicationException) {
+               if(e == null) {
+                   // Timed out?
+                   routes.searchFailed(System.currentTimeMillis());
+               } else if(e instanceof CommunicationException) {
                    ++unreachable;
                    // don't care if it's terminal or nonterminal
                    // because routing is too time-critical
+                   
+                   // It's not an error in opening the connection
+                   // It's an error in sending the message
                    CommunicationException ce = (CommunicationException)e;
                    if(logDEBUG)
                        n.logger.log(this, "Routing ("+this+") failure to: "
                                     +ce.peerAddress() + " -- " + ce, ce, 
                                     Logger.DEBUG);
-                   if (e instanceof AuthenticationFailedException) {
-                       routes.authFailed();
-                   } else {
-                       // Conn is dead
-                       routes.connectFailed();
-                   }
+                   // Conn is dead
+                   routes.searchFailed(System.currentTimeMillis());
                } else {
                    n.logger.log(this, "DataRequest send caught "+e, e,
                                 Logger.NORMAL);
@@ -692,6 +695,7 @@
                                      boolean sendAsync) throws RequestAbortException {
        if(sendAsync)
            feedbackSender = new SendFinished(n, id, "Restarted");
+       // We don't care if it takes forever, nothing is waiting for it
         try {
             ft.restarted(n, timeout, 
                         sendAsync ? feedbackSender : null);

_______________________________________________
cvs mailing list
[EMAIL PROTECTED]
http://dodo.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to