Commit 73c80095 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

1) Improved performance when removing sessions.

2) Fixed recursivity problem. JM-645

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@3783 b35dd754-fafc-0310-a699-88a17e54d16e
parent 4fed312c
......@@ -1195,26 +1195,21 @@ public class SessionManager extends BasicModule {
* @param session the session.
*/
public void removeSession(ClientSession session) {
// TODO: Requires better error checking to ensure the session count is maintained
// TODO: properly (removal actually does remove).
// Do nothing if session is null or if the server is shutting down. Note: When the server
// is shutting down the serverName will be null.
if (session == null || serverName == null) {
return;
}
SessionMap sessionMap;
if (anonymousSessions.containsValue(session)) {
anonymousSessions.remove(session.getAddress().getResource());
if (anonymousSessions.remove(session.getAddress().getResource()) != null) {
// Fire session event.
SessionEventDispatcher.dispatchEvent(session,
SessionEventDispatcher.EventType.anonymous_session_destroyed);
}
else {
// If this is a non-anonymous session then remove the session from the SessionMap
if (session.getAddress() != null &&
userManager.isRegisteredUser(session.getAddress().getNode())) {
String username = session.getAddress().getNode();
if (session.getAddress() != null && userManager.isRegisteredUser(username)) {
SessionMap sessionMap;
synchronized (username.intern()) {
sessionMap = sessions.get(username);
if (sessionMap != null) {
......@@ -1231,19 +1226,17 @@ public class SessionManager extends BasicModule {
}
}
}
// Remove the session from the pre-Authenticated sessions list (if present)
preAuthenticatedSessions.remove(session.getAddress().getResource());
// If the user is still available then send an unavailable presence
Presence presence = session.getPresence();
if (presence == null || presence.isAvailable()) {
if (presence.isAvailable()) {
Presence offline = new Presence();
offline.setFrom(session.getAddress());
offline.setTo(new JID(null, serverName, null));
offline.setType(Presence.Type.unavailable);
router.route(offline);
}
else if (preAuthenticatedSessions.containsValue(session)) {
// Remove the session from the pre-Authenticated sessions list
preAuthenticatedSessions.remove(session.getAddress().getResource());
}
}
public void addAnonymousSession(ClientSession session) {
......
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