Commit e59d080f authored by Eugene Kosov's avatar Eugene Kosov Committed by Sergey Vojtovich

fix a data race in debug build (#456)

fix a data race in debug build

This particular one flooded TSAN report.
parent a4948daf
......@@ -76,7 +76,7 @@ class MutexDebug {
{
m_mutex = mutex;
m_thread_id = os_thread_get_curr_id();
my_atomic_storelint(&m_thread_id, os_thread_get_curr_id());
m_filename = filename;
......@@ -89,7 +89,7 @@ class MutexDebug {
{
m_mutex = NULL;
m_thread_id = os_thread_id_t(ULINT_UNDEFINED);
my_atomic_storelint(&m_thread_id, ULINT_UNDEFINED);
m_filename = NULL;
......@@ -138,7 +138,7 @@ class MutexDebug {
unsigned m_line;
/** Thread ID of the thread that own(ed) the mutex */
os_thread_id_t m_thread_id;
ulint m_thread_id;
};
/** Constructor. */
......@@ -157,7 +157,7 @@ class MutexDebug {
/** Mutex is being destroyed. */
void destroy() UNIV_NOTHROW
{
ut_ad(m_context.m_thread_id == os_thread_id_t(ULINT_UNDEFINED));
ut_ad((ulint)my_atomic_loadlint(&m_context.m_thread_id) == ULINT_UNDEFINED);
m_magic_n = 0;
......@@ -199,7 +199,7 @@ class MutexDebug {
bool is_owned() const UNIV_NOTHROW
{
return(os_thread_eq(
m_context.m_thread_id,
my_atomic_loadlint(&m_context.m_thread_id),
os_thread_get_curr_id()));
}
......@@ -221,7 +221,7 @@ class MutexDebug {
os_thread_id_t get_thread_id() const
UNIV_NOTHROW
{
return(m_context.m_thread_id);
return(my_atomic_loadlint(&m_context.m_thread_id));
}
/** Magic number to check for memory corruption. */
......
......@@ -80,7 +80,7 @@ void MutexDebug<Mutex>::locked(
UNIV_NOTHROW
{
ut_ad(!is_owned());
ut_ad(m_context.m_thread_id == os_thread_id_t(ULINT_UNDEFINED));
ut_ad(m_context.m_thread_id == ULINT_UNDEFINED);
m_context.locked(mutex, name, line);
......
......@@ -1163,10 +1163,12 @@ enum rw_lock_flag_t {
#ifdef _WIN64
#define my_atomic_addlint(A,B) my_atomic_add64((int64*) (A), (B))
#define my_atomic_loadlint(A) my_atomic_load64((int64*) (A))
#define my_atomic_storelint(A,B) my_atomic_store64((int64*) (A), (B))
#define my_atomic_caslint(A,B,C) my_atomic_cas64((int64*) (A), (int64*) (B), (C))
#else
#define my_atomic_addlint my_atomic_addlong
#define my_atomic_loadlint my_atomic_loadlong
#define my_atomic_storelint my_atomic_storelong
#define my_atomic_caslint my_atomic_caslong
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment