diff options
Diffstat (limited to 'mysys/thr_mutex.c')
-rw-r--r-- | mysys/thr_mutex.c | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/mysys/thr_mutex.c b/mysys/thr_mutex.c index bd53ee433e8..b5548662679 100644 --- a/mysys/thr_mutex.c +++ b/mysys/thr_mutex.c @@ -171,12 +171,12 @@ static int safe_mutex_lazy_init_deadlock_detection(safe_mutex_t *mp) pthread_mutex_lock(&THR_LOCK_mutex); mp->id= ++safe_mutex_id; pthread_mutex_unlock(&THR_LOCK_mutex); - hash_init(mp->locked_mutex, &my_charset_bin, + my_hash_init(mp->locked_mutex, &my_charset_bin, 1000, offsetof(safe_mutex_deadlock_t, id), sizeof(mp->id), 0, 0, HASH_UNIQUE); - hash_init(mp->used_mutex, &my_charset_bin, + my_hash_init(mp->used_mutex, &my_charset_bin, 1000, offsetof(safe_mutex_t, id), sizeof(mp->id), @@ -186,10 +186,7 @@ static int safe_mutex_lazy_init_deadlock_detection(safe_mutex_t *mp) int safe_mutex_init(safe_mutex_t *mp, const pthread_mutexattr_t *attr __attribute__((unused)), - const char *name, - myf my_flags, - const char *file, - uint line) + const char *name, const char *file, uint line) { DBUG_ENTER("safe_mutex_init"); DBUG_PRINT("enter",("mutex: 0x%lx name: %s", (ulong) mp, name)); @@ -202,11 +199,9 @@ int safe_mutex_init(safe_mutex_t *mp, /* Skip the very common '&' prefix from the autogenerated name */ mp->name= name[0] == '&' ? name + 1 : name; - if (!safe_mutex_deadlock_detector) - my_flags|= MYF_NO_DEADLOCK_DETECTION; /* Deadlock detection is initialised only lazily, on first use. */ - mp->create_flags= my_flags; + mp->create_flags= safe_mutex_deadlock_detector ? MYF_NO_DEADLOCK_DETECTION : 0; #ifdef SAFE_MUTEX_DETECT_DESTROY /* @@ -342,7 +337,7 @@ int safe_mutex_lock(safe_mutex_t *mp, myf my_flags, const char *file, */ pthread_mutex_lock(&THR_LOCK_mutex); - if (!hash_search(mutex_root->locked_mutex, (uchar*) &mp->id, 0)) + if (!my_hash_search(mutex_root->locked_mutex, (uchar*) &mp->id, 0)) { safe_mutex_deadlock_t *deadlock; safe_mutex_t *mutex; @@ -362,7 +357,7 @@ int safe_mutex_lock(safe_mutex_t *mp, myf my_flags, const char *file, mutex= mutex_root; do { - if (hash_search(mp->locked_mutex, (uchar*) &mutex->id, 0)) + if (my_hash_search(mp->locked_mutex, (uchar*) &mutex->id, 0)) { print_deadlock_warning(mp, mutex); /* Mark wrong usage to avoid future warnings for same error */ @@ -669,9 +664,9 @@ void safe_mutex_free_deadlock_data(safe_mutex_t *mp) mp); pthread_mutex_unlock(&THR_LOCK_mutex); - hash_free(mp->used_mutex); - hash_free(mp->locked_mutex); - my_free(mp->locked_mutex, 0); + my_hash_free(mp->used_mutex); + my_hash_free(mp->locked_mutex); + my_free(mp->locked_mutex); mp->create_flags|= MYF_NO_DEADLOCK_DETECTION; } } @@ -718,8 +713,7 @@ void safe_mutex_end(FILE *file __attribute__((unused))) safe_mutex_t **my_thread_var_mutex_in_use() { - struct st_my_thread_var *tmp= - my_pthread_getspecific(struct st_my_thread_var*,THR_KEY_mysys); + struct st_my_thread_var *tmp= my_thread_var; return tmp ? &tmp->mutex_in_use : 0; } @@ -785,17 +779,17 @@ static my_bool remove_from_locked_mutex(safe_mutex_t *mp, (ulong) delete_mutex, (ulong) mp, delete_mutex->id, mp->id)); - found= (safe_mutex_deadlock_t *) hash_search(mp->locked_mutex, + found= (safe_mutex_deadlock_t *) my_hash_search(mp->locked_mutex, (uchar*) &delete_mutex->id, 0); DBUG_ASSERT(found); if (found) { - if (hash_delete(mp->locked_mutex, (uchar*) found)) + if (my_hash_delete(mp->locked_mutex, (uchar*) found)) { DBUG_ASSERT(0); } if (!--found->count) - my_free(found, MYF(0)); + my_free(found); } DBUG_RETURN(0); } @@ -807,12 +801,12 @@ static my_bool remove_from_used_mutex(safe_mutex_deadlock_t *locked_mutex, DBUG_PRINT("enter", ("delete_mutex: 0x%lx mutex: 0x%lx (id: %lu <- %lu)", (ulong) mutex, (ulong) locked_mutex, mutex->id, locked_mutex->id)); - if (hash_delete(locked_mutex->mutex->used_mutex, (uchar*) mutex)) + if (my_hash_delete(locked_mutex->mutex->used_mutex, (uchar*) mutex)) { DBUG_ASSERT(0); } if (!--locked_mutex->count) - my_free(locked_mutex, MYF(0)); + my_free(locked_mutex); DBUG_RETURN(0); } |