From de0cdbc01cc39e4f89a9d012661031a66ba3294f Mon Sep 17 00:00:00 2001 From: sapier Date: Sat, 30 Nov 2013 21:22:15 +0100 Subject: Fix log threadname lookup handling not beeing threadsafe --- src/jthread/pthread/jmutex.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'src/jthread/pthread') 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; } -- cgit v1.2.3