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,25 +203,22 @@ public class NIOConnection implements Connection {
}
public void close() {
boolean closedSuccessfully = false;
synchronized (this) {
if (!isClosed()) {
try {
deliverRawText(flashClient ? "</flash:stream>" : "</stream:stream>", false);
} catch (Exception e) {
// Ignore
}
if (session != null) {
session.setStatus(Session.STATUS_CLOSED);
}
ioSession.close(false);
closed = true;
closedSuccessfully = true;
synchronized(this) {
if (isClosed()) {
return;
}
try {
deliverRawText(flashClient ? "</flash:stream>" : "</stream:stream>", false);
} catch (Exception e) {
// Ignore
}
}
if (closedSuccessfully) {
notifyCloseListeners();
}
if (session != null) {
session.setStatus(Session.STATUS_CLOSED);
}
notifyCloseListeners(); // clean up session, etc.
closed = true;
}
ioSession.close(false); // async via MINA
}
public void systemShutdown() {
......@@ -248,11 +245,8 @@ public class NIOConnection implements Connection {
session = owner;
}
public boolean isClosed() {
if (session == null) {
return closed;
}
return session.getStatus() == Session.STATUS_CLOSED;
public synchronized boolean isClosed() {
return closed;
}
public boolean isSecure() {
......
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