diff options
Diffstat (limited to 'storage/innobase/include/sync0sync.ic')
-rw-r--r-- | storage/innobase/include/sync0sync.ic | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/storage/innobase/include/sync0sync.ic b/storage/innobase/include/sync0sync.ic index f9017230497..a5887b1fd6f 100644 --- a/storage/innobase/include/sync0sync.ic +++ b/storage/innobase/include/sync0sync.ic @@ -80,15 +80,11 @@ ib_mutex_test_and_set( ib_mutex_t* mutex) /*!< in: mutex */ { #if defined(HAVE_ATOMIC_BUILTINS) -# if defined(HAVE_ATOMIC_BUILTINS_BYTE) - return(os_atomic_test_and_set_byte(&mutex->lock_word, 1)); -# else - return(os_atomic_test_and_set_ulint(&mutex->lock_word, 1)); -# endif + return(os_atomic_test_and_set_byte_acquire(&mutex->lock_word, 1)); #else ibool ret; - ret = os_fast_mutex_trylock(&(mutex->os_fast_mutex)); + ret = os_fast_mutex_trylock_full_barrier(&(mutex->os_fast_mutex)); if (ret == 0) { /* We check that os_fast_mutex_trylock does not leak @@ -96,7 +92,6 @@ ib_mutex_test_and_set( ut_a(mutex->lock_word == 0); mutex->lock_word = 1; - os_wmb; } return((byte) ret); @@ -113,11 +108,14 @@ mutex_reset_lock_word( ib_mutex_t* mutex) /*!< in: mutex */ { #if defined(HAVE_ATOMIC_BUILTINS) - os_atomic_lock_release_byte(&mutex->lock_word); + /* In theory __sync_lock_release should be used to release the lock. + Unfortunately, it does not work properly alone. The workaround is + that more conservative __sync_lock_test_and_set is used instead. */ + os_atomic_test_and_set_byte_release(&mutex->lock_word, 0); #else mutex->lock_word = 0; - os_fast_mutex_unlock(&(mutex->os_fast_mutex)); + os_fast_mutex_unlock_full_barrier(&(mutex->os_fast_mutex)); #endif } @@ -149,7 +147,6 @@ mutex_get_waiters( ptr = &(mutex->waiters); - os_rmb; return(*ptr); /* Here we assume that the read of a single word from memory is atomic */ } @@ -184,7 +181,6 @@ mutex_exit_func( to wake up possible hanging threads if they are missed in mutex_signal_object. */ - os_isync; if (mutex_get_waiters(mutex) != 0) { mutex_signal_object(mutex); |