Core/Network: Fix race condition in WorldSession timeout

Helgrind log:
 Lock at 0x2BD582E0 was first observed
  at : pthread_mutex_init (hg_intercepts.c:443)
  by : ACE_OS::mutex_init(pthread_mutex_t*, int, char const*, pthread_mutexattr_t*, int, int) (in /usr/lib/libACE-6.0.3.so)
  by : ACE_Thread_Mutex::ACE_Thread_Mutex(char const*, pthread_mutexattr_t*) (in /usr/lib/libACE-6.0.3.so)
  by : WorldSocket::WorldSocket() (WorldSocket.cpp:106)
  by : ACE_Acceptor<WorldSocket, ACE_SOCK_Acceptor>::make_svc_handler(WorldSocket*&) (Acceptor.cpp:261)
  by : ACE_Acceptor<WorldSocket, ACE_SOCK_Acceptor>::handle_input(int) (Acceptor.cpp:396)
  by : ACE_Dev_Poll_Reactor::dispatch_io_event(ACE_Dev_Poll_Reactor::Token_Guard&) (in /usr/lib/libACE-6.0.3.so)
  by : ACE_Dev_Poll_Reactor::handle_events(ACE_Time_Value*) (in /usr/lib/libACE-6.0.3.so)
  by : ACE_Reactor::run_reactor_event_loop(ACE_Time_Value&, int (*)(ACE_Reactor*)) (in /usr/lib/libACE-6.0.3.so)
  by : ReactorRunnable::svc() (WorldSocketMgr.cpp:170)
  by : ACE_Task_Base::svc_run(void*) (in /usr/lib/libACE-6.0.3.so)
  by : ACE_Thread_Adapter::invoke_i() (in /usr/lib/libACE-6.0.3.so)

 Possible data race during write of size 8 at 0x2BD6F6F8 by thread #12
 Locks held: 1, at address 0x2BD582E0
  at : WorldSession::ResetTimeOutTime() (WorldSession.h:372)
  by : WorldSocket::ProcessIncoming(WorldPacket*) (WorldSocket.cpp:709)
  by : WorldSocket::handle_input_payload() (WorldSocket.cpp:517)
  by : WorldSocket::handle_input_missing_data() (WorldSocket.cpp:610)
  by : WorldSocket::handle_input(int) (WorldSocket.cpp:282)
  by : ACE_Dev_Poll_Reactor::dispatch_io_event(ACE_Dev_Poll_Reactor::Token_Guard&) (in /usr/lib/libACE-6.0.3.so)
  by : ACE_Dev_Poll_Reactor::handle_events(ACE_Time_Value*) (in /usr/lib/libACE-6.0.3.so)
  by : ACE_Reactor::run_reactor_event_loop(ACE_Time_Value&, int (*)(ACE_Reactor*)) (in /usr/lib/libACE-6.0.3.so)
  by : ReactorRunnable::svc() (WorldSocketMgr.cpp:170)
  by : ACE_Task_Base::svc_run(void*) (in /usr/lib/libACE-6.0.3.so)
  by : ACE_Thread_Adapter::invoke_i() (in /usr/lib/libACE-6.0.3.so)
  by : ACE_Thread_Adapter::invoke() (in /usr/lib/libACE-6.0.3.so)

 This conflicts with a previous write of size 8 by thread #7
 Locks held: none
  at : WorldSession::UpdateTimeOutTime(unsigned int) (WorldSession.h:368)
  by : WorldSession::Update(unsigned int, PacketFilter&) (WorldSession.cpp:256)
  by : World::UpdateSessions(unsigned int) (World.cpp:2646)
  by : World::Update(unsigned int) (World.cpp:2003)
  by : WorldRunnable::run() (WorldRunnable.cpp:60)
  by : ACE_Based::Thread::ThreadTask(void*) (Threading.cpp:186)
  by : ACE_OS_Thread_Adapter::invoke() (in /usr/lib/libACE-6.0.3.so)
  by : mythread_wrapper (hg_intercepts.c:233)
This commit is contained in:
jackpoz
2013-11-03 18:07:17 +01:00
parent bc6920a80b
commit bcee801e4b

View File

@@ -359,10 +359,10 @@ class WorldSession
void ResetClientTimeDelay() { m_clientTimeDelay = 0; }
uint32 getDialogStatus(Player* player, Object* questgiver, uint32 defstatus);
time_t m_timeOutTime;
ACE_Atomic_Op<ACE_Thread_Mutex, time_t> m_timeOutTime;
void UpdateTimeOutTime(uint32 diff)
{
if (time_t(diff) > m_timeOutTime)
if (time_t(diff) > m_timeOutTime.value())
m_timeOutTime = 0;
else
m_timeOutTime -= diff;