Author: toad
Date: 2006-07-08 12:13:36 +0000 (Sat, 08 Jul 2006)
New Revision: 9504

Modified:
   trunk/freenet/src/freenet/io/xfer/PartiallyReceivedBlock.java
   trunk/freenet/src/freenet/node/Version.java
Log:
864: Fix deadlock in 863. MANDATORY at 0:00 GMT 10/07/06.

Modified: trunk/freenet/src/freenet/io/xfer/PartiallyReceivedBlock.java
===================================================================
--- trunk/freenet/src/freenet/io/xfer/PartiallyReceivedBlock.java       
2006-07-08 11:17:26 UTC (rev 9503)
+++ trunk/freenet/src/freenet/io/xfer/PartiallyReceivedBlock.java       
2006-07-08 12:13:36 UTC (rev 9504)
@@ -96,20 +96,30 @@
                return _packetSize;
        }

-       public synchronized void addPacket(int position, Buffer packet) throws 
AbortedException {
-               if (_aborted) {
-                       throw new AbortedException("PRB is aborted");
+       public void addPacket(int position, Buffer packet) throws 
AbortedException {
+               
+               PacketReceivedListener[] prls;
+               
+               synchronized(this) {
+                       if (_aborted) {
+                               throw new AbortedException("PRB is aborted");
+                       }
+                       if (packet.getLength() != _packetSize) {
+                               throw new RuntimeException("New packet size 
"+packet.getLength()+" but expecting packet of size "+_packetSize);
+                       }
+                       if (!_received[position]) {
+                               _receivedCount++;
+                       }
+                       packet.copyTo(_data, position * _packetSize);
+                       _received[position] = true;
+                       
+                       // FIXME keep it as as an array
+                       prls = (PacketReceivedListener[]) 
_packetReceivedListeners.toArray(new 
PacketReceivedListener[_packetReceivedListeners.size()]);
                }
-               if (packet.getLength() != _packetSize) {
-                       throw new RuntimeException("New packet size 
"+packet.getLength()+" but expecting packet of size "+_packetSize);
-               }
-               if (!_received[position]) {
-                       _receivedCount++;
-               }
-               packet.copyTo(_data, position * _packetSize);
-               _received[position] = true;
-               for (Iterator i = _packetReceivedListeners.iterator(); 
i.hasNext();) {
-                       PacketReceivedListener prl = (PacketReceivedListener) 
i.next();
+               
+               
+               for (int i=0;i<prls.length;i++) {
+                       PacketReceivedListener prl = prls[i];
                        prl.packetReceived(position);
                }
        }

Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2006-07-08 11:17:26 UTC (rev 
9503)
+++ trunk/freenet/src/freenet/node/Version.java 2006-07-08 12:13:36 UTC (rev 
9504)
@@ -18,12 +18,12 @@
        public static final String protocolVersion = "1.0";

        /** The build number of the current revision */
-       private static final int buildNumber = 863;
+       private static final int buildNumber = 864;

        /** Oldest build of Fred we will talk to */
-       private static final int oldLastGoodBuild = 839;
-       private static final int newLastGoodBuild = 844;
-       private static final long transitionTime = 1151625600000L; // 0:00 GMT 
30/06/06
+       private static final int oldLastGoodBuild = 844;
+       private static final int newLastGoodBuild = 864;
+       private static final long transitionTime = 1152489600000L; // 0:00 GMT 
30/06/06

        public static final int buildNumber() {
                return buildNumber;


Reply via email to