diff options
author | Loic Blot <loic.blot@unix-experience.fr> | 2015-03-22 20:09:44 +0100 |
---|---|---|
committer | Loic Blot <loic.blot@unix-experience.fr> | 2015-03-22 20:47:07 +0100 |
commit | 0e5e49736c0a5fa29bca257bafc02d7c7a7171c9 (patch) | |
tree | 87d7e19f8082099f2570d8094ba75167cf5a7f35 /src/player.h | |
parent | d6638b4300b091275fa25c43eaee42cd6d13effe (diff) | |
download | minetest-0e5e49736c0a5fa29bca257bafc02d7c7a7171c9.tar.gz minetest-0e5e49736c0a5fa29bca257bafc02d7c7a7171c9.tar.bz2 minetest-0e5e49736c0a5fa29bca257bafc02d7c7a7171c9.zip |
Protect Player::hud from concurrent modifications
Sometimes HUD can be modified by ServerThread and EmergeThread results in a crash on client side because the HUD is not correct
Diffstat (limited to 'src/player.h')
-rw-r--r-- | src/player.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/player.h b/src/player.h index def428847..f38bd5615 100644 --- a/src/player.h +++ b/src/player.h @@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "irrlichttypes_bloated.h" #include "inventory.h" #include "constants.h" // BS +#include "jthread/jmutexautolock.h" #include <list> #define PLAYERNAME_SIZE 20 @@ -202,7 +203,8 @@ public: return m_collisionbox; } - u32 getFreeHudID() const { + u32 getFreeHudID() { + JMutexAutoLock lock(m_mutex); size_t size = hud.size(); for (size_t i = 0; i != size; i++) { if (!hud[i]) @@ -318,6 +320,11 @@ protected: bool m_dirty; std::vector<HudElement *> hud; +private: + // Protect some critical areas + // hud for example can be modified by EmergeThread + // and ServerThread + JMutex m_mutex; }; |