Author: toad
Date: 2008-03-14 18:09:46 +0000 (Fri, 14 Mar 2008)
New Revision: 18534

Modified:
   trunk/freenet/src/freenet/io/xfer/BlockTransmitter.java
Log:
Detect excessive waits, and don't wake up every 10 seconds.

Modified: trunk/freenet/src/freenet/io/xfer/BlockTransmitter.java
===================================================================
--- trunk/freenet/src/freenet/io/xfer/BlockTransmitter.java     2008-03-14 
18:07:48 UTC (rev 18533)
+++ trunk/freenet/src/freenet/io/xfer/BlockTransmitter.java     2008-03-14 
18:09:46 UTC (rev 18534)
@@ -294,10 +294,13 @@
        }

        public void waitForComplete() {
+       long deadline = System.currentTimeMillis() + 60*60*1000;
                synchronized(_senderThread) {
                        while(!_sendComplete) {
                                try {
-                                       _senderThread.wait(10*1000);
+                       long now = System.currentTimeMillis();
+                       if(now > deadline) throw new 
IllegalStateException("Waited more than 1 hour for transfer completion!");
+                       wait(deadline - now);
                                } catch (InterruptedException e) {
                                        // Ignore
                                }
@@ -306,10 +309,13 @@
        }

        public boolean getAsyncExitStatus() {
+       long deadline = System.currentTimeMillis() + 60*60*1000;
                synchronized (this) {
                        while (!asyncExitStatusSet) {
                                try {
-                                       this.wait(10*1000);
+                       long now = System.currentTimeMillis();
+                       if(now > deadline) throw new 
IllegalStateException("Waited more than 1 hour for transfer completion!");
+                       wait(deadline - now);
                                } catch (InterruptedException e) {
                                        //ignore
                                }


Reply via email to