Commit 9e95c34f authored by Guus der Kinderen's avatar Guus der Kinderen Committed by Dave Cridland

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

The close listeners should not be called from within a synchronized block.
parent 0cd1edef
...@@ -208,8 +208,10 @@ public class NIOConnection implements Connection { ...@@ -208,8 +208,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 )
...@@ -235,8 +237,7 @@ public class NIOConnection implements Connection { ...@@ -235,8 +237,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
...@@ -250,6 +251,11 @@ public class NIOConnection implements Connection { ...@@ -250,6 +251,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