Merge pull request #10694 from jackpoz/loopcounter_race_condition

Core/Thread: Fix race condition in FreezeDetectorRunnable
This commit is contained in:
Nay
2013-09-01 10:05:39 -07:00
3 changed files with 5 additions and 4 deletions

View File

@@ -83,7 +83,7 @@
ACE_Atomic_Op<ACE_Thread_Mutex, bool> World::m_stopEvent = false;
uint8 World::m_ExitCode = SHUTDOWN_EXIT_CODE;
volatile uint32 World::m_worldLoopCounter = 0;
ACE_Atomic_Op<ACE_Thread_Mutex, uint32> World::m_worldLoopCounter = 0;
float World::m_MaxVisibleDistanceOnContinents = DEFAULT_VISIBILITY_DISTANCE;
float World::m_MaxVisibleDistanceInInstances = DEFAULT_VISIBILITY_INSTANCE;

View File

@@ -514,7 +514,7 @@ struct CharacterNameData
class World
{
public:
static volatile uint32 m_worldLoopCounter;
static ACE_Atomic_Op<ACE_Thread_Mutex, uint32> m_worldLoopCounter;
World();
~World();

View File

@@ -103,10 +103,11 @@ public:
ACE_Based::Thread::Sleep(1000);
uint32 curtime = getMSTime();
// normal work
if (_loops != World::m_worldLoopCounter)
uint32 worldLoopCounter = World::m_worldLoopCounter.value();
if (_loops != worldLoopCounter)
{
_lastChange = curtime;
_loops = World::m_worldLoopCounter;
_loops = worldLoopCounter;
}
// possible freeze
else if (getMSTimeDiff(_lastChange, curtime) > _delaytime)