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 { ...@@ -1195,26 +1195,21 @@ public class SessionManager extends BasicModule {
* @param session the session. * @param session the session.
*/ */
public void removeSession(ClientSession 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 // 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. // is shutting down the serverName will be null.
if (session == null || serverName == null) { if (session == null || serverName == null) {
return; return;
} }
SessionMap sessionMap; if (anonymousSessions.remove(session.getAddress().getResource()) != null) {
if (anonymousSessions.containsValue(session)) {
anonymousSessions.remove(session.getAddress().getResource());
// Fire session event. // Fire session event.
SessionEventDispatcher.dispatchEvent(session, SessionEventDispatcher.dispatchEvent(session,
SessionEventDispatcher.EventType.anonymous_session_destroyed); SessionEventDispatcher.EventType.anonymous_session_destroyed);
} }
else { else {
// If this is a non-anonymous session then remove the session from the SessionMap // 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(); String username = session.getAddress().getNode();
if (session.getAddress() != null && userManager.isRegisteredUser(username)) {
SessionMap sessionMap;
synchronized (username.intern()) { synchronized (username.intern()) {
sessionMap = sessions.get(username); sessionMap = sessions.get(username);
if (sessionMap != null) { if (sessionMap != null) {
...@@ -1231,19 +1226,17 @@ public class SessionManager extends BasicModule { ...@@ -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 // If the user is still available then send an unavailable presence
Presence presence = session.getPresence(); Presence presence = session.getPresence();
if (presence == null || presence.isAvailable()) { if (presence.isAvailable()) {
Presence offline = new Presence(); Presence offline = new Presence();
offline.setFrom(session.getAddress()); offline.setFrom(session.getAddress());
offline.setTo(new JID(null, serverName, null)); offline.setTo(new JID(null, serverName, null));
offline.setType(Presence.Type.unavailable); offline.setType(Presence.Type.unavailable);
router.route(offline); 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) { 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