Add MX lock to InstanceSave::Add/RemovePlayer. Because BindToInstance can be called within Player::Update.

Try to fix crashes #2514 and #2177. May also fix #3466, #2862 and #2239.
This commit is contained in:
megamage
2011-10-12 11:36:03 -04:00
parent 10d0a250ef
commit 69414ed065
+4 -2
View File
@@ -80,8 +80,8 @@ class InstanceSave
/* online players bound to the instance (perm/solo) /* online players bound to the instance (perm/solo)
does not include the members of the group unless they have permanent saves */ does not include the members of the group unless they have permanent saves */
void AddPlayer(Player* player) { m_playerList.push_back(player); } void AddPlayer(Player* player) { ACE_GUARD(ACE_Thread_Mutex, guard, _lock); m_playerList.push_back(player); }
bool RemovePlayer(Player* player) { m_playerList.remove(player); return UnloadIfEmpty(); } bool RemovePlayer(Player* player) { ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, _lock, false); m_playerList.remove(player); return UnloadIfEmpty(); }
/* all groups bound to the instance */ /* all groups bound to the instance */
void AddGroup(Group* group) { m_groupList.push_back(group); } void AddGroup(Group* group) { m_groupList.push_back(group); }
bool RemoveGroup(Group* group) { m_groupList.remove(group); return UnloadIfEmpty(); } bool RemoveGroup(Group* group) { m_groupList.remove(group); return UnloadIfEmpty(); }
@@ -110,6 +110,8 @@ class InstanceSave
uint32 m_mapid; uint32 m_mapid;
Difficulty m_difficulty; Difficulty m_difficulty;
bool m_canReset; bool m_canReset;
ACE_Thread_Mutex _lock;
}; };
typedef UNORDERED_MAP<uint32 /*PAIR32(map, difficulty)*/, time_t /*resetTime*/> ResetTimeByMapDifficultyMap; typedef UNORDERED_MAP<uint32 /*PAIR32(map, difficulty)*/, time_t /*resetTime*/> ResetTimeByMapDifficultyMap;