Skip to content

Commit

Permalink
Player: Fix a deadlock triggered by previous commit 0e5e497
Browse files Browse the repository at this point in the history
  • Loading branch information
nerzhul committed Mar 22, 2015
1 parent 0e5e497 commit 0ae75f2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "player.h"

#include <fstream>
#include "jthread/jmutexautolock.h"
#include "util/numeric.h"
#include "hud.h"
#include "constants.h"
Expand Down Expand Up @@ -241,6 +242,7 @@ void Player::deSerialize(std::istream &is, std::string playername)
u32 Player::addHud(HudElement *toadd)
{
JMutexAutoLock lock(m_mutex);

u32 id = getFreeHudID();

if (id < hud.size())
Expand Down
3 changes: 1 addition & 2 deletions src/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +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 "jthread/jmutex.h"
#include <list>

#define PLAYERNAME_SIZE 20
Expand Down Expand Up @@ -204,7 +204,6 @@ class Player
}

u32 getFreeHudID() {
JMutexAutoLock lock(m_mutex);
size_t size = hud.size();
for (size_t i = 0; i != size; i++) {
if (!hud[i])
Expand Down

0 comments on commit 0ae75f2

Please sign in to comment.