Author: robert
Date: 2008-01-29 16:15:53 +0000 (Tue, 29 Jan 2008)
New Revision: 17389
Modified:
trunk/freenet/src/freenet/io/comm/MessageCore.java
trunk/freenet/src/freenet/io/comm/MessageFilter.java
Log:
remove callback sideeffect from anyConnectionsDropped()
Modified: trunk/freenet/src/freenet/io/comm/MessageCore.java
===================================================================
--- trunk/freenet/src/freenet/io/comm/MessageCore.java 2008-01-29 16:14:39 UTC
(rev 17388)
+++ trunk/freenet/src/freenet/io/comm/MessageCore.java 2008-01-29 16:15:53 UTC
(rev 17389)
@@ -298,8 +298,10 @@
filter.onStartWaiting();
if(logMINOR) Logger.minor(this, "Adding async filter "+filter+"
for "+callback);
Message ret = null;
- if(filter.anyConnectionsDropped())
+ if(filter.anyConnectionsDropped()) {
throw new DisconnectedException();
+ //or... filter.onDroppedConnection(filter.getSource());
+ }
// Check to see whether the filter matches any of the recently
_unclaimed messages
// Drop any _unclaimed messages that the filter doesn't match
that are also older than MAX_UNCLAIMED_FIFO_ITEM_LIFETIME
long now = System.currentTimeMillis();
@@ -310,6 +312,8 @@
//have disconnected between check above and locking, so
we *must* check again.
if(filter.anyConnectionsDropped()) {
throw new DisconnectedException();
+ //or...
filter.onDroppedConnection(filter.getSource());
+ //but we are holding the _filters lock!
}
if(logMINOR) Logger.minor(this, "Checking _unclaimed");
for (ListIterator i = _unclaimed.listIterator();
i.hasNext();) {
@@ -374,8 +378,10 @@
}
filter.onStartWaiting();
Message ret = null;
- if(filter.anyConnectionsDropped())
+ if(filter.anyConnectionsDropped()) {
+ filter.onDroppedConnection(filter.getSource());
throw new DisconnectedException();
+ }
// Check to see whether the filter matches any of the recently
_unclaimed messages
// Drop any _unclaimed messages that the filter doesn't match
that are also older than MAX_UNCLAIMED_FIFO_ITEM_LIFETIME
long now = System.currentTimeMillis();
Modified: trunk/freenet/src/freenet/io/comm/MessageFilter.java
===================================================================
--- trunk/freenet/src/freenet/io/comm/MessageFilter.java 2008-01-29
16:14:39 UTC (rev 17388)
+++ trunk/freenet/src/freenet/io/comm/MessageFilter.java 2008-01-29
16:15:53 UTC (rev 17389)
@@ -331,14 +331,15 @@
_callback.onTimeout();
}
+ /**
+ * Returns true if a connection related to this filter has been dropped
or restarted.
+ */
public boolean anyConnectionsDropped() {
if(_matched) return false;
if(_source != null) {
if(!_source.isConnected()) {
- onDroppedConnection(_source);
return true;
} else if(_source.getBootID() != _oldBootID) {
- onRestartedConnection(_source);
return true; // Counts as a disconnect.
}
}