Make the Eluna mutex static.
It was previously unsafe to reload Eluna because it had to be reloaded with the mutex unlocked. This is because the mutex's lifespan was shorter than the Eluna instance it was guarding.
This commit is contained in:
@@ -463,13 +463,13 @@ void Eluna::OnShutdownCancel()
|
||||
|
||||
void Eluna::OnWorldUpdate(uint32 diff)
|
||||
{
|
||||
ELUNA_LOCK(this);
|
||||
if (reload)
|
||||
{
|
||||
ReloadEluna();
|
||||
return;
|
||||
}
|
||||
|
||||
ELUNA_LOCK(this);
|
||||
eventMgr->globalProcessor->Update(diff);
|
||||
|
||||
Push(diff);
|
||||
|
||||
@@ -36,6 +36,7 @@ std::string Eluna::lua_requirepath;
|
||||
Eluna* Eluna::GEluna = NULL;
|
||||
bool Eluna::reload = false;
|
||||
bool Eluna::initialized = false;
|
||||
Eluna::LockType Eluna::lock;
|
||||
|
||||
extern void RegisterFunctions(Eluna* E);
|
||||
|
||||
|
||||
@@ -159,10 +159,10 @@ public:
|
||||
typedef std::lock_guard<LockType> ElunaGuard;
|
||||
#else
|
||||
typedef ACE_Recursive_Thread_Mutex LockType;
|
||||
typedef ACE_Guard<LockType> ElunaGuard;
|
||||
typedef ACE_Guard<LockType> Guard;
|
||||
#endif
|
||||
|
||||
LockType elunaLock;
|
||||
static LockType lock;
|
||||
|
||||
lua_State* L;
|
||||
uint32 event_level;
|
||||
@@ -459,5 +459,5 @@ template<> WorldObject* Eluna::CHECKOBJ<WorldObject>(lua_State* L, int narg, boo
|
||||
template<> ElunaObject* Eluna::CHECKOBJ<ElunaObject>(lua_State* L, int narg, bool error);
|
||||
|
||||
#define sEluna Eluna::GEluna
|
||||
#define ELUNA_LOCK(E) Eluna::ElunaGuard elunaGuard((E)->elunaLock);
|
||||
#define ELUNA_LOCK(E) Eluna::Guard __guard(Eluna::lock);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user