Author: robert
Date: 2008-01-04 18:22:10 +0000 (Fri, 04 Jan 2008)
New Revision: 16886

Modified:
   trunk/freenet/src/freenet/node/RequestSender.java
Log:
do not continue a search which has already locally timed out


Modified: trunk/freenet/src/freenet/node/RequestSender.java
===================================================================
--- trunk/freenet/src/freenet/node/RequestSender.java   2008-01-04 17:22:34 UTC 
(rev 16885)
+++ trunk/freenet/src/freenet/node/RequestSender.java   2008-01-04 18:22:10 UTC 
(rev 16886)
@@ -136,6 +136,7 @@
                pubKey = ((NodeSSK)key).getPubKey();
         }

+               long startTime=System.currentTimeMillis();
         HashSet nodesRoutedTo = new HashSet();
         HashSet nodesNotIgnored = new HashSet();
         while(true) {
@@ -145,6 +146,12 @@
                 finish(DATA_NOT_FOUND, null);
                 return;
             }
+                       
+                       if (source!=null && 
System.currentTimeMillis()-startTime>FETCH_TIMEOUT) {
+                               Logger.error(this, "discontinuing non-local 
request search, general timeout");
+                               finish(TIMED_OUT, null);
+                               return;
+                       }

             // Route it
             PeerNode next;
@@ -586,6 +593,7 @@
      */
     public synchronized short waitUntilStatusChange(short mask) {
        if(mask == WAIT_ALL) throw new IllegalArgumentException("Cannot ignore 
all!");
+               long startTime=System.currentTimeMillis();
         while(true) {
                short current = mask; // If any bits are set already, we ignore 
those states.

@@ -605,6 +613,10 @@
             } catch (InterruptedException e) {
                 // Ignore
             }
+                       if (source!=null && 
System.currentTimeMillis()-startTime > 2*FETCH_TIMEOUT) {
+                               Logger.error(this, "spending way too long 
waiting for request sender to finish");
+                               throw new RuntimeException("something is 
broken");
+                       }
         }
     }



Reply via email to