Author: toad
Date: 2008-01-17 12:34:47 +0000 (Thu, 17 Jan 2008)
New Revision: 17088

Modified:
   trunk/freenet/src/freenet/io/comm/MessageFilter.java
Log:
Prevent race conditions missing connection restarts.

Modified: trunk/freenet/src/freenet/io/comm/MessageFilter.java
===================================================================
--- trunk/freenet/src/freenet/io/comm/MessageFilter.java        2008-01-17 
12:33:03 UTC (rev 17087)
+++ trunk/freenet/src/freenet/io/comm/MessageFilter.java        2008-01-17 
12:34:47 UTC (rev 17088)
@@ -49,6 +49,7 @@
     private Message _message;
     private boolean _matchesDroppedConnections;
     private boolean _matchesRestartedConnections;
+    private long _oldBootID;
     private AsyncMessageFilterCallback _callback;

     private MessageFilter() {
@@ -107,6 +108,8 @@

        public MessageFilter setSource(PeerContext source) {
                _source = source;
+               if(source != null)
+                       _oldBootID = source.getBootID();
                return this;
        }

@@ -309,6 +312,10 @@
                        onDroppedConnection(_source);
                        return true;
                }
+               if(_source != null && _source.getBootID() != _oldBootID) {
+                       onRestartedConnection(_source);
+                       return true; // Counts as a disconnect.
+               }
                if(_or != null)
                        return _or.anyConnectionsDropped();
                return false;


Reply via email to