diff --git a/src/glx/glxcurrent.c b/src/glx/glxcurrent.c index 43469c3..f27fd4b 100644 --- a/src/glx/glxcurrent.c +++ b/src/glx/glxcurrent.c @@ -83,7 +83,7 @@ static __GLapi *IndirectAPI = NULL; #if defined( PTHREADS ) -_X_HIDDEN pthread_mutex_t __glXmutex = PTHREAD_MUTEX_INITIALIZER; +_X_HIDDEN pthread_mutex_t __glXmutex; # if defined( GLX_USE_TLS ) @@ -126,6 +126,20 @@ static pthread_key_t ContextTSD; static void init_thread_data(void) { + pthread_mutexattr_t attr; + + if (pthread_mutexattr_init(&attr) != 0) { + perror("pthread_mutexattr_init"); + exit(-1); + } + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); + + if (pthread_mutex_init(&__glXmutex, &attr) != 0) { + perror("pthread_mutex_init"); + exit(-1); + } + pthread_mutexattr_destroy(&attr); + if (pthread_key_create(&ContextTSD, NULL) != 0) { perror("pthread_key_create"); exit(-1);