Commit 1b2dd66e authored by Guus der Kinderen's avatar Guus der Kinderen

OF-883 & OF-881: Avoid potential deadlock with close listeners.

The close listeners should not be called from within a synchronized block.
parent c51067b8
...@@ -219,8 +219,10 @@ public class NIOConnection implements Connection { ...@@ -219,8 +219,10 @@ public class NIOConnection implements Connection {
return backupDeliverer; return backupDeliverer;
} }
public synchronized void close() public void close()
{ {
boolean notifyClose = false;
synchronized ( this ) {
try try
{ {
if ( state == State.CLOSED ) if ( state == State.CLOSED )
...@@ -246,8 +248,7 @@ public class NIOConnection implements Connection { ...@@ -246,8 +248,7 @@ public class NIOConnection implements Connection {
// to invoke the CloseListeners again. // to invoke the CloseListeners again.
if ( state == State.CLOSING ) if ( state == State.CLOSING )
{ {
// TODO Check for regression of OF-881 (which placed the call below outside of the synchronized block). notifyClose = true;
notifyCloseListeners(); // clean up session, etc.
} }
} }
finally finally
...@@ -261,6 +262,11 @@ public class NIOConnection implements Connection { ...@@ -261,6 +262,11 @@ public class NIOConnection implements Connection {
ioSession.close( true ); ioSession.close( true );
} }
} }
if (notifyClose)
{
notifyCloseListeners(); // clean up session, etc.
}
}
public void systemShutdown() { public void systemShutdown() {
deliverRawText("<stream:error><system-shutdown " + deliverRawText("<stream:error><system-shutdown " +
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment