1
0
mirror of https://github.com/MariaDB/server.git synced 2026-01-06 05:22:24 +03:00

Fix for SAFE_MUTEX on windows

This commit is contained in:
monty@donna.mysql.com
2000-09-20 19:37:07 +03:00
parent 2780278f35
commit 830d308960
9 changed files with 46 additions and 21 deletions

View File

@@ -77,10 +77,19 @@ void my_thread_global_end(void)
static long thread_id=0;
/*
We can't use mutex_locks here if we re using windows as
we may have compiled the program with SAFE_MUTEX, in which
case the checking of mutex_locks will not work until
the pthread_self thread specific variable is initialized.
*/
my_bool my_thread_init(void)
{
struct st_my_thread_var *tmp;
#if !defined(__WIN__) || defined(USE_TLS) || ! defined(SAFE_MUTEX)
pthread_mutex_lock(&THR_LOCK_lock);
#endif
#if !defined(__WIN__) || defined(USE_TLS)
if (my_pthread_getspecific(struct st_my_thread_var *,THR_KEY_mysys))
{
@@ -98,9 +107,11 @@ my_bool my_thread_init(void)
pthread_setspecific(THR_KEY_mysys,tmp);
#else
if (THR_KEY_mysys.id) /* Allready initialized */
if (THR_KEY_mysys.id) /* Already initialized */
{
#if !defined(__WIN__) || defined(USE_TLS) || ! defined(SAFE_MUTEX)
pthread_mutex_unlock(&THR_LOCK_lock);
#endif
return 0;
}
tmp= &THR_KEY_mysys;
@@ -108,7 +119,9 @@ my_bool my_thread_init(void)
tmp->id= ++thread_id;
pthread_mutex_init(&tmp->mutex,NULL);
pthread_cond_init(&tmp->suspend, NULL);
#if !defined(__WIN__) || defined(USE_TLS) || ! defined(SAFE_MUTEX)
pthread_mutex_unlock(&THR_LOCK_lock);
#endif
return 0;
}