Author: toad
Date: 2007-06-01 19:52:31 +0000 (Fri, 01 Jun 2007)
New Revision: 13454

Modified:
   trunk/freenet/src/freenet/io/comm/MessageFilter.java
   trunk/freenet/src/freenet/io/comm/UdpSocketManager.java
Log:
Timeouts must be relative to the time of starting waiting, NOT relative to the 
creation of the filter!

Modified: trunk/freenet/src/freenet/io/comm/MessageFilter.java
===================================================================
--- trunk/freenet/src/freenet/io/comm/MessageFilter.java        2007-06-01 
19:43:36 UTC (rev 13453)
+++ trunk/freenet/src/freenet/io/comm/MessageFilter.java        2007-06-01 
19:52:31 UTC (rev 13454)
@@ -58,6 +58,15 @@
         return new MessageFilter();
     }

+    void onStartWaiting() {
+       synchronized(this) {
+               if(_initialTimeout > 0)
+                       _timeout = System.currentTimeMillis() + _initialTimeout;
+       }
+       if(_or != null)
+               _or.onStartWaiting();
+    }
+    
     /**
      * This filter will expire after the specificed amount of time. Note also 
that where two or more filters match the
      * same message, the one with the nearer expiry time will get priority

Modified: trunk/freenet/src/freenet/io/comm/UdpSocketManager.java
===================================================================
--- trunk/freenet/src/freenet/io/comm/UdpSocketManager.java     2007-06-01 
19:43:36 UTC (rev 13453)
+++ trunk/freenet/src/freenet/io/comm/UdpSocketManager.java     2007-06-01 
19:52:31 UTC (rev 13454)
@@ -497,6 +497,7 @@

        public void addAsyncFilter(MessageFilter filter, 
AsyncMessageFilterCallback callback) throws DisconnectedException {
                filter.setAsyncCallback(callback);
+               filter.onStartWaiting();
                boolean logDEBUG = Logger.shouldLog(Logger.DEBUG, this);
                if(logDEBUG) Logger.debug(this, "Adding async filter "+filter+" 
for "+callback);
                Message ret = null;
@@ -566,6 +567,7 @@
                boolean logDEBUG = Logger.shouldLog(Logger.DEBUG, this);
                if(logDEBUG) Logger.debug(this, "Waiting for "+filter);
                long startTime = System.currentTimeMillis();
+               filter.onStartWaiting();
                Message ret = null;
                if((lowLevelFilter != null) && (filter._source != null) && 
                        filter.matchesDroppedConnection(filter._source) &&


Reply via email to