diff options
| author | slewis | 2005-01-28 06:19:44 +0000 |
|---|---|---|
| committer | slewis | 2005-01-28 06:19:44 +0000 |
| commit | 7f590f4c78dc9f1b0de9af87f6c978a6cd2b75e5 (patch) | |
| tree | 682c408dfc5cf003e13a880ef08b8a17b581de5f | |
| parent | b2a860c8b808c55b0523204bc135802d775e9f89 (diff) | |
| download | org.eclipse.ecf-7f590f4c78dc9f1b0de9af87f6c978a6cd2b75e5.tar.gz org.eclipse.ecf-7f590f4c78dc9f1b0de9af87f6c978a6cd2b75e5.tar.xz org.eclipse.ecf-7f590f4c78dc9f1b0de9af87f6c978a6cd2b75e5.zip | |
Fixes for bug in handling of unexpected disconnect from clients and/or server
2 files changed, 17 insertions, 9 deletions
diff --git a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/comm/tcp/Client.java b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/comm/tcp/Client.java index d9fa5e534..08a715513 100644 --- a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/comm/tcp/Client.java +++ b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/comm/tcp/Client.java @@ -298,14 +298,13 @@ public final class Client implements ISynchAsynchConnection { } else msgCount++; } catch (IOException e) { - //dumpStack("read",e); if (isClosing) { isClosing = false; synchronized (Client.this) { Client.this.notifyAll(); } } else { - if (handler.handleSuspectEvent(new ConnectionEvent( + if (!handler.handleSuspectEvent(new ConnectionEvent( Client.this, e))) { handler .handleDisconnectEvent(new DisconnectConnectionEvent( @@ -378,14 +377,13 @@ public final class Client implements ISynchAsynchConnection { try { handleRcv(readObject()); } catch (IOException e) { - //dumpStack("read",e); if (isClosing) { isClosing = false; synchronized (Client.this) { Client.this.notifyAll(); } } else { - if (handler.handleSuspectEvent(new ConnectionEvent( + if (!handler.handleSuspectEvent(new ConnectionEvent( Client.this, e))) { handler .handleDisconnectEvent(new DisconnectConnectionEvent( @@ -484,14 +482,13 @@ public final class Client implements ISynchAsynchConnection { } } } catch (Exception e) { - //dumpStack("ping",e); if (isClosing) { isClosing = false; synchronized (Client.this) { Client.this.notifyAll(); } } else { - if (handler.handleSuspectEvent(new ConnectionEvent( + if (!handler.handleSuspectEvent(new ConnectionEvent( Client.this, e))) { handler .handleDisconnectEvent(new DisconnectConnectionEvent( diff --git a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SOContainer.java b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SOContainer.java index b06abcaa1..2d05d0fc1 100644 --- a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SOContainer.java +++ b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SOContainer.java @@ -35,10 +35,12 @@ import org.eclipse.ecf.core.SharedObjectInitException; import org.eclipse.ecf.core.comm.AsynchConnectionEvent; import org.eclipse.ecf.core.comm.ConnectionEvent; import org.eclipse.ecf.core.comm.DisconnectConnectionEvent; +import org.eclipse.ecf.core.comm.IAsynchConnection; import org.eclipse.ecf.core.comm.IConnection; import org.eclipse.ecf.core.comm.ISynchAsynchConnectionEventHandler; import org.eclipse.ecf.core.comm.SynchConnectionEvent; import org.eclipse.ecf.core.events.IContainerEvent; +import org.eclipse.ecf.core.events.SharedObjectContainerDepartedEvent; import org.eclipse.ecf.core.events.SharedObjectContainerDisposeEvent; import org.eclipse.ecf.core.identity.ID; import org.eclipse.ecf.core.util.Event; @@ -376,7 +378,6 @@ public abstract class SOContainer implements ISharedObjectContainer { // Clear group manager if (groupManager != null) { groupManager.removeAllMembers(); - groupManager = null; } // Clear shared object manager if (sharedObjectManager != null) { @@ -393,7 +394,7 @@ public abstract class SOContainer implements ISharedObjectContainer { } if (listeners != null) { listeners.clear(); - listeners = null; + listeners = null; } } @@ -949,10 +950,20 @@ public abstract class SOContainer implements ISharedObjectContainer { } } + protected abstract ID getIDForConnection(IAsynchConnection connection); + protected void processDisconnect(DisconnectConnectionEvent e) { debug("processDisconnect:" + e); try { - ContainerMessage mess = getObjectFromBytes((byte[]) e.getData()); + // Get connection responsible for disconnect event + IAsynchConnection conn = (IAsynchConnection) e.getConnection(); + if (!conn.isConnected()) return; + ID fromID = null; + synchronized (getGroupMembershipLock()) { + fromID = getIDForConnection(conn); + memberLeave(fromID,conn); + } + if (fromID != null) fireContainerEvent(new SharedObjectContainerDepartedEvent(getID(),fromID)); } catch (Exception except) { logException("Exception in processDisconnect ", except); } |
