diff options
author | sapier <Sapier at GMX dot net> | 2013-11-30 21:22:15 +0100 |
---|---|---|
committer | sapier <Sapier at GMX dot net> | 2013-11-30 21:22:15 +0100 |
commit | de0cdbc01cc39e4f89a9d012661031a66ba3294f (patch) | |
tree | 1d6e4bb56c41cd136028a5df896247225eb54820 /src/jthread | |
parent | e605d7025608f8d04cdd6143c6be85e35ef067e3 (diff) | |
download | minetest-de0cdbc01cc39e4f89a9d012661031a66ba3294f.tar.gz minetest-de0cdbc01cc39e4f89a9d012661031a66ba3294f.tar.bz2 minetest-de0cdbc01cc39e4f89a9d012661031a66ba3294f.zip |
Fix log threadname lookup handling not beeing threadsafe
Diffstat (limited to 'src/jthread')
-rw-r--r-- | src/jthread/pthread/jmutex.cpp | 14 | ||||
-rw-r--r-- | src/jthread/win32/jmutex.cpp | 19 |
2 files changed, 13 insertions, 20 deletions
diff --git a/src/jthread/pthread/jmutex.cpp b/src/jthread/pthread/jmutex.cpp index 29e0baac0..3dfad5e6c 100644 --- a/src/jthread/pthread/jmutex.cpp +++ b/src/jthread/pthread/jmutex.cpp @@ -29,7 +29,8 @@ JMutex::JMutex() { - initialized = false; + pthread_mutex_init(&mutex,NULL); + initialized = true; } JMutex::~JMutex() @@ -40,19 +41,14 @@ JMutex::~JMutex() int JMutex::Init() { - if (initialized) - return ERR_JMUTEX_ALREADYINIT; - - pthread_mutex_init(&mutex,NULL); - initialized = true; - return 0; + return 0; } int JMutex::Lock() { if (!initialized) return ERR_JMUTEX_NOTINIT; - + pthread_mutex_lock(&mutex); return 0; } @@ -61,7 +57,7 @@ int JMutex::Unlock() { if (!initialized) return ERR_JMUTEX_NOTINIT; - + pthread_mutex_unlock(&mutex); return 0; } diff --git a/src/jthread/win32/jmutex.cpp b/src/jthread/win32/jmutex.cpp index d079d448d..8a31495cd 100644 --- a/src/jthread/win32/jmutex.cpp +++ b/src/jthread/win32/jmutex.cpp @@ -29,7 +29,14 @@ JMutex::JMutex() { - initialized = false; +#ifdef JMUTEX_CRITICALSECTION + InitializeCriticalSection(&mutex); +#else + mutex = CreateMutex(NULL,FALSE,NULL); + if (mutex == NULL) + return ERR_JMUTEX_CANTCREATEMUTEX; +#endif // JMUTEX_CRITICALSECTION + initialized = true; } JMutex::~JMutex() @@ -44,16 +51,6 @@ JMutex::~JMutex() int JMutex::Init() { - if (initialized) - return ERR_JMUTEX_ALREADYINIT; -#ifdef JMUTEX_CRITICALSECTION - InitializeCriticalSection(&mutex); -#else - mutex = CreateMutex(NULL,FALSE,NULL); - if (mutex == NULL) - return ERR_JMUTEX_CANTCREATEMUTEX; -#endif // JMUTEX_CRITICALSECTION - initialized = true; return 0; } |