From 476cdcd2c372e30b60a61974726096418ec7cd08 Mon Sep 17 00:00:00 2001 From: Rochet2 Date: Wed, 25 Apr 2018 21:47:36 +0300 Subject: [PATCH] Try fix data race for people trying to mthread --- ElunaEventMgr.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ElunaEventMgr.cpp b/ElunaEventMgr.cpp index 2a2075c..c5309a8 100644 --- a/ElunaEventMgr.cpp +++ b/ElunaEventMgr.cpp @@ -16,6 +16,7 @@ extern "C" ElunaEventProcessor::ElunaEventProcessor(Eluna** _E, WorldObject* _obj) : m_time(0), obj(_obj), E(_E) { + // can be called from multiple threads if (obj) { EventMgr::Guard guard((*E)->eventMgr->GetLock()); @@ -25,7 +26,11 @@ ElunaEventProcessor::ElunaEventProcessor(Eluna** _E, WorldObject* _obj) : m_time ElunaEventProcessor::~ElunaEventProcessor() { - RemoveEvents_internal(); + // can be called from multiple threads + { + LOCK_ELUNA; + RemoveEvents_internal(); + } if (obj && Eluna::IsInitialized()) {