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 {
return backupDeliverer;
}
public synchronized void close()
public void close()
{
boolean notifyClose = false;
synchronized ( this ) {
try
{
if ( state == State.CLOSED )
......@@ -246,8 +248,7 @@ public class NIOConnection implements Connection {
// to invoke the CloseListeners again.
if ( state == State.CLOSING )
{
// TODO Check for regression of OF-881 (which placed the call below outside of the synchronized block).
notifyCloseListeners(); // clean up session, etc.
notifyClose = true;
}
}
finally
......@@ -261,6 +262,11 @@ public class NIOConnection implements Connection {
ioSession.close( true );
}
}
if (notifyClose)
{
notifyCloseListeners(); // clean up session, etc.
}
}
public void systemShutdown() {
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