diff options
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/my_thr_init.c | 30 | ||||
-rw-r--r-- | mysys/thr_mutex.c | 2 |
2 files changed, 21 insertions, 11 deletions
diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index 36b37f68b46..878e1f6bfc6 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -41,7 +41,7 @@ pthread_mutex_t LOCK_gethostbyname_r; pthread_mutexattr_t my_fast_mutexattr; #endif #ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP -pthread_mutexattr_t my_errchk_mutexattr; +pthread_mutexattr_t my_errorcheck_mutexattr; #endif /* @@ -62,19 +62,29 @@ my_bool my_thread_global_init(void) fprintf(stderr,"Can't initialize threads: error %d\n",errno); return 1; } + #ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP - pthread_mutexattr_init(&my_fast_mutexattr); /* - Note that the following statement may give a compiler warning under - some configurations, but there isn't anything we can do about this as - this is a bug in the header files for the thread implementation + Set mutex type to "fast" a.k.a "adaptive" + + The mutex kind determines what happens if a thread attempts to lock + a mutex it already owns with pthread_mutex_lock(3). If the mutex + is of the ``fast'' kind, pthread_mutex_lock(3) simply suspends + the calling thread forever. If the mutex is of the ``error checking'' + kind, pthread_mutex_lock(3) returns immediately with the error + code EDEADLK. */ - pthread_mutexattr_setkind_np(&my_fast_mutexattr,PTHREAD_MUTEX_ADAPTIVE_NP); + pthread_mutexattr_init(&my_fast_mutexattr); + pthread_mutexattr_settype(&my_fast_mutexattr, + PTHREAD_MUTEX_ADAPTIVE_NP); #endif #ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP - pthread_mutexattr_init(&my_errchk_mutexattr); - pthread_mutexattr_setkind_np(&my_errchk_mutexattr, - PTHREAD_MUTEX_ERRORCHECK_NP); + /* + Set mutex type to "errorcheck" a.k.a "adaptive" + */ + pthread_mutexattr_init(&my_errorcheck_mutexattr); + pthread_mutexattr_settype(&my_errorcheck_mutexattr, + PTHREAD_MUTEX_ERRORCHECK); #endif pthread_mutex_init(&THR_LOCK_malloc,MY_MUTEX_INIT_FAST); @@ -110,7 +120,7 @@ void my_thread_global_end(void) pthread_mutexattr_destroy(&my_fast_mutexattr); #endif #ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP - pthread_mutexattr_destroy(&my_errchk_mutexattr); + pthread_mutexattr_destroy(&my_errorcheck_mutexattr); #endif pthread_mutex_destroy(&THR_LOCK_malloc); pthread_mutex_destroy(&THR_LOCK_open); diff --git a/mysys/thr_mutex.c b/mysys/thr_mutex.c index bbcfaa8bba6..2facb4e18cf 100644 --- a/mysys/thr_mutex.c +++ b/mysys/thr_mutex.c @@ -17,7 +17,7 @@ /* This makes a wrapper for mutex handling to make it easier to debug mutex */ #include <my_global.h> -#if defined(HAVE_LINUXTHREADS) && !defined (__USE_UNIX98) +#if defined(TARGET_OS_LINUX) && !defined (__USE_UNIX98) #define __USE_UNIX98 /* To get rw locks under Linux */ #endif #if defined(THREAD) && defined(SAFE_MUTEX) |