Commit 348d5bdc authored by Tom Evans's avatar Tom Evans

OF-857: Synchronize connection/session cleanup

This patch is to prevent a stack overflow in certain exception cases
where a connection has been closed, but its corresponding session is
still present in the routing table.
parent 111fe941
......@@ -203,9 +203,10 @@ public class NIOConnection implements Connection {
}
public void close() {
boolean closedSuccessfully = false;
synchronized (this) {
if (!isClosed()) {
synchronized(this) {
if (isClosed()) {
return;
}
try {
deliverRawText(flashClient ? "</flash:stream>" : "</stream:stream>", false);
} catch (Exception e) {
......@@ -214,14 +215,10 @@ public class NIOConnection implements Connection {
if (session != null) {
session.setStatus(Session.STATUS_CLOSED);
}
ioSession.close(false);
notifyCloseListeners(); // clean up session, etc.
closed = true;
closedSuccessfully = true;
}
}
if (closedSuccessfully) {
notifyCloseListeners();
}
ioSession.close(false); // async via MINA
}
public void systemShutdown() {
......@@ -248,12 +245,9 @@ public class NIOConnection implements Connection {
session = owner;
}
public boolean isClosed() {
if (session == null) {
public synchronized boolean isClosed() {
return closed;
}
return session.getStatus() == Session.STATUS_CLOSED;
}
public boolean isSecure() {
return ioSession.getFilterChain().contains(TLS_FILTER_NAME);
......
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