Author: toad
Date: 2008-08-06 17:06:49 +0000 (Wed, 06 Aug 2008)
New Revision: 21639

Modified:
   trunk/freenet/src/freenet/node/SeedClientPeerNode.java
Log:
Fix bug causing seednodes to connect and then remove the connection 
immediately, resulting in not sending us any packets.
Frequency of this bug varied according to how often PacketSender was run.

Modified: trunk/freenet/src/freenet/node/SeedClientPeerNode.java
===================================================================
--- trunk/freenet/src/freenet/node/SeedClientPeerNode.java      2008-08-06 
17:06:48 UTC (rev 21638)
+++ trunk/freenet/src/freenet/node/SeedClientPeerNode.java      2008-08-06 
17:06:49 UTC (rev 21639)
@@ -92,8 +92,14 @@
                if(!isConnected()) {
                        // SeedClientPeerNode's always start off unverified.
                        // If it doesn't manage to connect in 60 seconds, dump 
it.
-                       if(System.currentTimeMillis() - 
lastReceivedPacketTime() > 60*1000)
+                       // However, we don't want to be dumped *before* we 
connect,
+                       // so we need to check that first.
+                       // Synchronize to avoid messy races.
+                       synchronized(this) {
+                               if(timeLastConnectionCompleted() > 0 &&
+                                               System.currentTimeMillis() - 
lastReceivedPacketTime() > 60*1000)
                                return true;
+                       }
                }
                return false;
        }


Reply via email to