Author: toad
Date: 2005-11-25 15:01:14 +0000 (Fri, 25 Nov 2005)
New Revision: 7595

Modified:
   trunk/freenet/src/freenet/client/SplitFetcher.java
   trunk/freenet/src/freenet/io/xfer/BlockTransmitter.java
   trunk/freenet/src/freenet/node/Version.java
Log:
214 (mandatory):
Eliminate block transmitter thread leak caused by not notifying when set 
_sendComplete.
Minor progress fix (show out of needed rather than out of total on request).


Modified: trunk/freenet/src/freenet/client/SplitFetcher.java
===================================================================
--- trunk/freenet/src/freenet/client/SplitFetcher.java  2005-11-25 01:07:19 UTC 
(rev 7594)
+++ trunk/freenet/src/freenet/client/SplitFetcher.java  2005-11-25 15:01:14 UTC 
(rev 7595)
@@ -234,7 +234,7 @@
        }

        public void onProgress() {
-               int totalBlocks = splitfileDataBlocks.length + 
splitfileCheckBlocks.length;
+               int totalBlocks = splitfileDataBlocks.length;
                int fetchedBlocks = 0;
                int failedBlocks = 0;
                int fatallyFailedBlocks = 0;

Modified: trunk/freenet/src/freenet/io/xfer/BlockTransmitter.java
===================================================================
--- trunk/freenet/src/freenet/io/xfer/BlockTransmitter.java     2005-11-25 
01:07:19 UTC (rev 7594)
+++ trunk/freenet/src/freenet/io/xfer/BlockTransmitter.java     2005-11-25 
15:01:14 UTC (rev 7595)
@@ -92,7 +92,7 @@
                                                                }
                                                                
if(_sendComplete) return;
                                                                synchronized 
(_senderThread) {
-                                                                       
_senderThread.wait();
+                                                                       
_senderThread.wait(10*1000);
                                                                }
                                                        }
                                                } catch (InterruptedException 
e) {  }
@@ -144,7 +144,10 @@

                while (true) {
                        if (_prb.isAborted()) {
-                               _sendComplete = true;
+                               synchronized(_senderThread) {
+                                       _sendComplete = true;
+                                       notifyAll();
+                               }
                                return false;
                        }
                        Message msg;
@@ -152,13 +155,19 @@
                 msg = 
_usm.waitFor(MessageFilter.create().setTimeout(SEND_TIMEOUT).setType(DMT.missingPacketNotification).setField(DMT.UID,
 _uid).or(MessageFilter.create().setType(DMT.allReceived).setField(DMT.UID, 
_uid)));
             } catch (DisconnectedException e) {
                 Logger.normal(this, "Terminating send "+_uid+" to 
"+_destination+" from "+_usm.getPortNumber()+" because node disconnected while 
waiting");
-                _sendComplete = true;
+                synchronized(_senderThread) {
+                       _sendComplete = true;
+                       notifyAll();
+                }
                 return false;
             }
                        if(_sendComplete || !_destination.isConnected()) return 
false;
                        if (msg == null) {
                                if (getNumSent() == _prb.getNumPackets()) {
-                                       _sendComplete = true;
+                                       synchronized(_senderThread) {
+                                               _sendComplete = true;
+                                               notifyAll();
+                                       }
                                        Logger.error(this, "Terminating send 
"+_uid+" to "+_destination+" from "+_usm.getPortNumber()+" as we haven't heard 
from receiver in "+SEND_TIMEOUT+"ms.");
                                        return false;
                                }
@@ -177,7 +186,10 @@
                                        }
                                }
                        } else if (msg.getSpec().equals(DMT.allReceived)) {
-                               _sendComplete = true;
+                               synchronized(_senderThread) {
+                                       _sendComplete = true;
+                                       notifyAll();
+                               }
                                return true;
                        } else if(_sendComplete) {
                            // Terminated abnormally
@@ -186,7 +198,10 @@
                }
                } catch (AbortedException e) {
                        // Terminate
-                       _sendComplete = true;
+                       synchronized(_senderThread) {
+                               _sendComplete = true;
+                               notifyAll();
+                       }
                        return false;
                }
        }

Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2005-11-25 01:07:19 UTC (rev 
7594)
+++ trunk/freenet/src/freenet/node/Version.java 2005-11-25 15:01:14 UTC (rev 
7595)
@@ -20,10 +20,10 @@
        public static final String protocolVersion = "1.0";

        /** The build number of the current revision */
-       public static final int buildNumber = 213;
+       public static final int buildNumber = 214;

        /** Oldest build of Fred we will talk to */
-       public static final int lastGoodBuild = 211;
+       public static final int lastGoodBuild = 214;

        /** The highest reported build of fred */
        public static int highestSeenBuild = buildNumber;


Reply via email to