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