Author: toad
Date: 2008-03-21 22:11:38 +0000 (Fri, 21 Mar 2008)
New Revision: 18699

Modified:
   trunk/freenet/src/freenet/io/xfer/PacketThrottle.java
Log:
It is essential that we notifyAll() after sending a packet: we were the next 
slot, the next but one may already have woken up and gone back to sleep.

Modified: trunk/freenet/src/freenet/io/xfer/PacketThrottle.java
===================================================================
--- trunk/freenet/src/freenet/io/xfer/PacketThrottle.java       2008-03-21 
21:39:59 UTC (rev 18698)
+++ trunk/freenet/src/freenet/io/xfer/PacketThrottle.java       2008-03-21 
22:11:38 UTC (rev 18699)
@@ -206,6 +206,19 @@
                                        throw new 
ThrottleDeprecatedException(_deprecatedFor);
                                }
                        }
+                       /** Because we send in order, we have to go around all 
the waiters again after sending.
+                        * Otherwise, we will miss slots:
+                        * Seq = 0
+                        * A: Wait for seq = 1
+                        * B: Wait for seq = 2
+                        * Packet acked
+                        * Packet acked
+                        * B: I'm not next since seq = 0 and I'm waiting for 2. 
Do nothing.
+                        * A: I'm next because seq = 0 and I'm waiting for 1. 
Send a packet.
+                        * A sends, B doesn't, even though it ought to: its 
slot is lost, and this can cause big 
+                        * problems if we are sending more than one packet at a 
time.
+                        */
+                       notifyAll();
                }
                long waitTime = System.currentTimeMillis() - start;
                if(waitTime > 60*1000)


Reply via email to