Commit 4c4949eb authored by Tom Evans's avatar Tom Evans

OF-857: Mark connection closed before notifying

The connection close listener initiates a presence broadcast to
advertise its "unavailable" status. The current connection must be
marked closed before this occurs, so the presence stanza will not be
delivered to the newly closed connection.

Note that the synchronized block alone does not accomplish this because
the presence broadcast is delivered via that same thread that is
currently closing the connection, thus it already possesses the sync
object lock.

Also, note that the SessionManager should exclude the originating JID
when sending presence broadcasts to the user's other available
session(s).
parent 348d5bdc
...@@ -641,12 +641,14 @@ public class SessionManager extends BasicModule implements ClusterEventListener ...@@ -641,12 +641,14 @@ public class SessionManager extends BasicModule implements ClusterEventListener
JID searchJID = new JID(originatingResource.getNode(), originatingResource.getDomain(), null); JID searchJID = new JID(originatingResource.getNode(), originatingResource.getDomain(), null);
List<JID> addresses = routingTable.getRoutes(searchJID, null); List<JID> addresses = routingTable.getRoutes(searchJID, null);
for (JID address : addresses) { for (JID address : addresses) {
if (originatingResource != address) {
// Send the presence of the session whose presence has changed to // Send the presence of the session whose presence has changed to
// this other user's session // this user's other session(s)
presence.setTo(address); presence.setTo(address);
routingTable.routePacket(address, presence, false); routingTable.routePacket(address, presence, false);
} }
} }
}
/** /**
* Notification message sent when a client sent an unavailable presence for the session. Making * Notification message sent when a client sent an unavailable presence for the session. Making
......
...@@ -215,8 +215,8 @@ public class NIOConnection implements Connection { ...@@ -215,8 +215,8 @@ public class NIOConnection implements Connection {
if (session != null) { if (session != null) {
session.setStatus(Session.STATUS_CLOSED); session.setStatus(Session.STATUS_CLOSED);
} }
notifyCloseListeners(); // clean up session, etc.
closed = true; closed = true;
notifyCloseListeners(); // clean up session, etc.
} }
ioSession.close(false); // async via MINA ioSession.close(false); // async via MINA
} }
......
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