Commit dc6cc970 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Fixed ghost problem that might happen under heavy load. JM-531

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@3324 b35dd754-fafc-0310-a699-88a17e54d16e
parent e0b0205d
...@@ -66,8 +66,16 @@ public interface MUCUser extends ChannelHandler { ...@@ -66,8 +66,16 @@ public interface MUCUser extends ChannelHandler {
Iterator<MUCRole> getRoles(); Iterator<MUCRole> getRoles();
/** /**
* Removes the role of the use in a particular room.<p> * Adds the role of the user in a particular room.
* <p/> *
* @param roomName The name of the room.
* @param role The new role of the user.
*/
void addRole(String roomName, MUCRole role);
/**
* Removes the role of the user in a particular room.<p>
*
* Note: PREREQUISITE: A lock on this object has already been obtained. * Note: PREREQUISITE: A lock on this object has already been obtained.
* *
* @param roomName The name of the room we're being removed * @param roomName The name of the room we're being removed
......
...@@ -120,6 +120,8 @@ public class MUCRoleImpl implements MUCRole { ...@@ -120,6 +120,8 @@ public class MUCRoleImpl implements MUCRole {
calculateExtendedInformation(); calculateExtendedInformation();
rJID = new JID(room.getName(), server.getServiceDomain(), nick); rJID = new JID(room.getName(), server.getServiceDomain(), nick);
setPresence(presence); setPresence(presence);
// Add the new role to the list of roles
user.addRole(room.getName(), this);
} }
public Presence getPresence() { public Presence getPresence() {
......
...@@ -78,6 +78,10 @@ public class MUCUserImpl implements MUCUser { ...@@ -78,6 +78,10 @@ public class MUCUserImpl implements MUCUser {
return Collections.unmodifiableCollection(roles.values()).iterator(); return Collections.unmodifiableCollection(roles.values()).iterator();
} }
public void addRole(String roomName, MUCRole role) {
roles.put(roomName.toLowerCase(), role);
}
public void removeRole(String roomName) { public void removeRole(String roomName) {
roles.remove(roomName.toLowerCase()); roles.remove(roomName.toLowerCase());
} }
...@@ -406,7 +410,6 @@ public class MUCUserImpl implements MUCUser { ...@@ -406,7 +410,6 @@ public class MUCUserImpl implements MUCUser {
historyRequest, historyRequest,
this, this,
packet.createCopy()); packet.createCopy());
roles.put(group.toLowerCase(), role);
// If the client that created the room is non-MUC compliant then // If the client that created the room is non-MUC compliant then
// unlock the room thus creating an "instant" room // unlock the room thus creating an "instant" room
if (mucInfo == null && room.isLocked() && !room.isManuallyLocked()) { if (mucInfo == null && room.isLocked() && !room.isManuallyLocked()) {
...@@ -464,7 +467,7 @@ public class MUCUserImpl implements MUCUser { ...@@ -464,7 +467,7 @@ public class MUCUserImpl implements MUCUser {
else { else {
if (Presence.Type.unavailable == packet.getType()) { if (Presence.Type.unavailable == packet.getType()) {
try { try {
roles.remove(group.toLowerCase()); removeRole(group);
role.getChatRoom().leaveRoom(role.getNickname()); role.getChatRoom().leaveRoom(role.getNickname());
} }
catch (UserNotFoundException e) { catch (UserNotFoundException e) {
......
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