Commit 7e8ed285 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

1) Fixed concurrency problem with counting of authenticated sessions. JM-1041

2) Route unavailable presence using packet router. JM-1043

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@8105 b35dd754-fafc-0310-a699-88a17e54d16e
parent a45dd32f
...@@ -16,7 +16,6 @@ import org.jivesoftware.openfire.auth.UnauthorizedException; ...@@ -16,7 +16,6 @@ import org.jivesoftware.openfire.auth.UnauthorizedException;
import org.jivesoftware.openfire.component.InternalComponentManager; import org.jivesoftware.openfire.component.InternalComponentManager;
import org.jivesoftware.openfire.container.BasicModule; import org.jivesoftware.openfire.container.BasicModule;
import org.jivesoftware.openfire.event.SessionEventDispatcher; import org.jivesoftware.openfire.event.SessionEventDispatcher;
import org.jivesoftware.openfire.handler.PresenceUpdateHandler;
import org.jivesoftware.openfire.http.HttpSession; import org.jivesoftware.openfire.http.HttpSession;
import org.jivesoftware.openfire.multiplex.ConnectionMultiplexerManager; import org.jivesoftware.openfire.multiplex.ConnectionMultiplexerManager;
import org.jivesoftware.openfire.server.OutgoingSessionPromise; import org.jivesoftware.openfire.server.OutgoingSessionPromise;
...@@ -50,7 +49,6 @@ public class SessionManager extends BasicModule { ...@@ -50,7 +49,6 @@ public class SessionManager extends BasicModule {
public static final int NEVER_KICK = -1; public static final int NEVER_KICK = -1;
private PresenceUpdateHandler presenceHandler;
private PacketRouter router; private PacketRouter router;
private String serverName; private String serverName;
private JID serverAddress; private JID serverAddress;
...@@ -1508,8 +1506,10 @@ public class SessionManager extends BasicModule { ...@@ -1508,8 +1506,10 @@ public class SessionManager extends BasicModule {
if (sessionMap != null) { if (sessionMap != null) {
synchronized (username.intern()) { synchronized (username.intern()) {
auth_removed = sessionMap.removeSession(session); auth_removed = sessionMap.removeSession(session);
// Decrement number of authenticated sessions (of non-anonymous users) if (auth_removed) {
userSessionsCounter.decrementAndGet(); // Decrement number of authenticated sessions (of non-anonymous users)
userSessionsCounter.decrementAndGet();
}
} }
if (sessionMap.isEmpty()) { if (sessionMap.isEmpty()) {
sessions.remove(username); sessions.remove(username);
...@@ -1580,14 +1580,15 @@ public class SessionManager extends BasicModule { ...@@ -1580,14 +1580,15 @@ public class SessionManager extends BasicModule {
try { try {
ClientSession session = (ClientSession) handback; ClientSession session = (ClientSession) handback;
try { try {
if (session.getPresence().isAvailable() || !session.wasAvailable()) { if ((session.getPresence().isAvailable() || !session.wasAvailable()) &&
getSession(session.getAddress()) != null) {
// Send an unavailable presence to the user's subscribers // Send an unavailable presence to the user's subscribers
// Note: This gives us a chance to send an unavailable presence to the // Note: This gives us a chance to send an unavailable presence to the
// entities that the user sent directed presences // entities that the user sent directed presences
Presence presence = new Presence(); Presence presence = new Presence();
presence.setType(Presence.Type.unavailable); presence.setType(Presence.Type.unavailable);
presence.setFrom(session.getAddress()); presence.setFrom(session.getAddress());
presenceHandler.process(presence, session); router.route(presence);
} }
} }
finally { finally {
...@@ -1685,7 +1686,6 @@ public class SessionManager extends BasicModule { ...@@ -1685,7 +1686,6 @@ public class SessionManager extends BasicModule {
public void initialize(XMPPServer server) { public void initialize(XMPPServer server) {
super.initialize(server); super.initialize(server);
presenceHandler = server.getPresenceUpdateHandler();
router = server.getPacketRouter(); router = server.getPacketRouter();
userManager = server.getUserManager(); userManager = server.getUserManager();
routingTable = server.getRoutingTable(); routingTable = server.getRoutingTable();
......
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