diff options
| author | megamage <none@none.none> | 2011-10-12 11:36:03 -0400 |
|---|---|---|
| committer | megamage <none@none.none> | 2011-10-12 11:36:03 -0400 |
| commit | 69414ed06547956a3cba507124d821028bbc5b90 (patch) | |
| tree | ba0178b84b96fbfd2af53863b9a79c852d3cd92a /src | |
| parent | 10d0a250efb2ff7a4a69388cf0029033e3f9e34b (diff) | |
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.
Diffstat (limited to 'src')
| -rwxr-xr-x | src/server/game/Instances/InstanceSaveMgr.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/server/game/Instances/InstanceSaveMgr.h b/src/server/game/Instances/InstanceSaveMgr.h index 63d54e4ec94..dec50e40127 100755 --- a/src/server/game/Instances/InstanceSaveMgr.h +++ b/src/server/game/Instances/InstanceSaveMgr.h @@ -80,8 +80,8 @@ class InstanceSave /* online players bound to the instance (perm/solo) does not include the members of the group unless they have permanent saves */ - void AddPlayer(Player* player) { m_playerList.push_back(player); } - bool RemovePlayer(Player* player) { m_playerList.remove(player); return UnloadIfEmpty(); } + void AddPlayer(Player* player) { ACE_GUARD(ACE_Thread_Mutex, guard, _lock); m_playerList.push_back(player); } + 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 */ void AddGroup(Group* group) { m_groupList.push_back(group); } bool RemoveGroup(Group* group) { m_groupList.remove(group); return UnloadIfEmpty(); } @@ -110,6 +110,8 @@ class InstanceSave uint32 m_mapid; Difficulty m_difficulty; bool m_canReset; + + ACE_Thread_Mutex _lock; }; typedef UNORDERED_MAP<uint32 /*PAIR32(map, difficulty)*/, time_t /*resetTime*/> ResetTimeByMapDifficultyMap; |
