Commit a6f80422 authored by Konstantin Osipov's avatar Konstantin Osipov

A post-merge fix for next-mr -> next-4284 merge:

Make all mutexes and conditions of type mysql_mutex_t, mysql_cond_t,
since it's now the expectation of THD::awake().
parent e7b332ba
...@@ -46,7 +46,7 @@ private: ...@@ -46,7 +46,7 @@ private:
/** All acquired locks in the server. */ /** All acquired locks in the server. */
HASH m_locks; HASH m_locks;
/* Protects access to m_locks hash. */ /* Protects access to m_locks hash. */
pthread_mutex_t m_mutex; mysql_mutex_t m_mutex;
}; };
...@@ -353,7 +353,7 @@ void mdl_destroy() ...@@ -353,7 +353,7 @@ void mdl_destroy()
void MDL_map::init() void MDL_map::init()
{ {
pthread_mutex_init(&m_mutex, NULL); mysql_mutex_init(NULL /* pfs key */,&m_mutex, NULL);
my_hash_init(&m_locks, &my_charset_bin, 16 /* FIXME */, 0, 0, my_hash_init(&m_locks, &my_charset_bin, 16 /* FIXME */, 0, 0,
mdl_locks_key, 0, 0); mdl_locks_key, 0, 0);
} }
...@@ -367,7 +367,7 @@ void MDL_map::init() ...@@ -367,7 +367,7 @@ void MDL_map::init()
void MDL_map::destroy() void MDL_map::destroy()
{ {
DBUG_ASSERT(!m_locks.records); DBUG_ASSERT(!m_locks.records);
pthread_mutex_destroy(&m_mutex); mysql_mutex_destroy(&m_mutex);
my_hash_free(&m_locks); my_hash_free(&m_locks);
} }
...@@ -389,7 +389,7 @@ MDL_lock* MDL_map::find_or_insert(const MDL_key *mdl_key) ...@@ -389,7 +389,7 @@ MDL_lock* MDL_map::find_or_insert(const MDL_key *mdl_key)
hash_value= my_calc_hash(&m_locks, mdl_key->ptr(), mdl_key->length()); hash_value= my_calc_hash(&m_locks, mdl_key->ptr(), mdl_key->length());
retry: retry:
pthread_mutex_lock(&m_mutex); mysql_mutex_lock(&m_mutex);
if (!(lock= (MDL_lock*) my_hash_search_using_hash_value(&m_locks, if (!(lock= (MDL_lock*) my_hash_search_using_hash_value(&m_locks,
hash_value, hash_value,
mdl_key->ptr(), mdl_key->ptr(),
...@@ -398,7 +398,7 @@ retry: ...@@ -398,7 +398,7 @@ retry:
lock= MDL_lock::create(mdl_key); lock= MDL_lock::create(mdl_key);
if (!lock || my_hash_insert(&m_locks, (uchar*)lock)) if (!lock || my_hash_insert(&m_locks, (uchar*)lock))
{ {
pthread_mutex_unlock(&m_mutex); mysql_mutex_unlock(&m_mutex);
MDL_lock::destroy(lock); MDL_lock::destroy(lock);
return NULL; return NULL;
} }
...@@ -427,13 +427,13 @@ MDL_lock* MDL_map::find(const MDL_key *mdl_key) ...@@ -427,13 +427,13 @@ MDL_lock* MDL_map::find(const MDL_key *mdl_key)
hash_value= my_calc_hash(&m_locks, mdl_key->ptr(), mdl_key->length()); hash_value= my_calc_hash(&m_locks, mdl_key->ptr(), mdl_key->length());
retry: retry:
pthread_mutex_lock(&m_mutex); mysql_mutex_lock(&m_mutex);
if (!(lock= (MDL_lock*) my_hash_search_using_hash_value(&m_locks, if (!(lock= (MDL_lock*) my_hash_search_using_hash_value(&m_locks,
hash_value, hash_value,
mdl_key->ptr(), mdl_key->ptr(),
mdl_key->length()))) mdl_key->length())))
{ {
pthread_mutex_unlock(&m_mutex); mysql_mutex_unlock(&m_mutex);
return NULL; return NULL;
} }
...@@ -457,7 +457,7 @@ retry: ...@@ -457,7 +457,7 @@ retry:
bool MDL_map::move_from_hash_to_lock_mutex(MDL_lock *lock) bool MDL_map::move_from_hash_to_lock_mutex(MDL_lock *lock)
{ {
DBUG_ASSERT(! lock->m_is_destroyed); DBUG_ASSERT(! lock->m_is_destroyed);
safe_mutex_assert_owner(&m_mutex); mysql_mutex_assert_owner(&m_mutex);
/* /*
We increment m_ref_usage which is a reference counter protected by We increment m_ref_usage which is a reference counter protected by
...@@ -465,7 +465,7 @@ bool MDL_map::move_from_hash_to_lock_mutex(MDL_lock *lock) ...@@ -465,7 +465,7 @@ bool MDL_map::move_from_hash_to_lock_mutex(MDL_lock *lock)
m_is_destroyed is FALSE. m_is_destroyed is FALSE.
*/ */
lock->m_ref_usage++; lock->m_ref_usage++;
pthread_mutex_unlock(&m_mutex); mysql_mutex_unlock(&m_mutex);
rw_wrlock(&lock->m_rwlock); rw_wrlock(&lock->m_rwlock);
lock->m_ref_release++; lock->m_ref_release++;
...@@ -520,13 +520,13 @@ void MDL_map::remove(MDL_lock *lock) ...@@ -520,13 +520,13 @@ void MDL_map::remove(MDL_lock *lock)
MDL_lock::m_rwlock we can safely read the m_ref_usage MDL_lock::m_rwlock we can safely read the m_ref_usage
member. member.
*/ */
pthread_mutex_lock(&m_mutex); mysql_mutex_lock(&m_mutex);
my_hash_delete(&m_locks, (uchar*) lock); my_hash_delete(&m_locks, (uchar*) lock);
lock->m_is_destroyed= TRUE; lock->m_is_destroyed= TRUE;
ref_usage= lock->m_ref_usage; ref_usage= lock->m_ref_usage;
ref_release= lock->m_ref_release; ref_release= lock->m_ref_release;
rw_unlock(&lock->m_rwlock); rw_unlock(&lock->m_rwlock);
pthread_mutex_unlock(&m_mutex); mysql_mutex_unlock(&m_mutex);
if (ref_usage == ref_release) if (ref_usage == ref_release)
MDL_lock::destroy(lock); MDL_lock::destroy(lock);
} }
...@@ -547,8 +547,8 @@ MDL_context::MDL_context() ...@@ -547,8 +547,8 @@ MDL_context::MDL_context()
m_signal(NO_WAKE_UP) m_signal(NO_WAKE_UP)
{ {
my_rwlock_init(&m_waiting_for_lock, NULL); my_rwlock_init(&m_waiting_for_lock, NULL);
pthread_mutex_init(&m_signal_lock, NULL); mysql_mutex_init(NULL /* pfs key */, &m_signal_lock, NULL);
pthread_cond_init(&m_signal_cond, NULL); mysql_cond_init(NULL /* pfs key */, &m_signal_cond, NULL);
} }
...@@ -569,8 +569,8 @@ void MDL_context::destroy() ...@@ -569,8 +569,8 @@ void MDL_context::destroy()
DBUG_ASSERT(m_tickets.is_empty()); DBUG_ASSERT(m_tickets.is_empty());
rwlock_destroy(&m_waiting_for_lock); rwlock_destroy(&m_waiting_for_lock);
pthread_mutex_destroy(&m_signal_lock); mysql_mutex_destroy(&m_signal_lock);
pthread_cond_destroy(&m_signal_cond); mysql_cond_destroy(&m_signal_cond);
} }
...@@ -729,16 +729,16 @@ void MDL_ticket::destroy(MDL_ticket *ticket) ...@@ -729,16 +729,16 @@ void MDL_ticket::destroy(MDL_ticket *ticket)
static inline const char *mdl_enter_cond(THD *thd, static inline const char *mdl_enter_cond(THD *thd,
st_my_thread_var *mysys_var, st_my_thread_var *mysys_var,
pthread_cond_t *cond, mysql_cond_t *cond,
pthread_mutex_t *mutex, mysql_mutex_t *mutex,
const char *calling_func, const char *calling_func,
const char *calling_file, const char *calling_file,
const unsigned int calling_line) const unsigned int calling_line)
{ {
safe_mutex_assert_owner(mutex); mysql_mutex_assert_owner(mutex);
mysys_var->current_mutex= (mysql_mutex_t*) mutex; mysys_var->current_mutex= mutex;
mysys_var->current_cond= (mysql_cond_t*) cond; mysys_var->current_cond= cond;
DEBUG_SYNC(thd, "mdl_enter_cond"); DEBUG_SYNC(thd, "mdl_enter_cond");
...@@ -751,18 +751,18 @@ static inline const char *mdl_enter_cond(THD *thd, ...@@ -751,18 +751,18 @@ static inline const char *mdl_enter_cond(THD *thd,
static inline void mdl_exit_cond(THD *thd, static inline void mdl_exit_cond(THD *thd,
st_my_thread_var *mysys_var, st_my_thread_var *mysys_var,
pthread_mutex_t *mutex, mysql_mutex_t *mutex,
const char* old_msg, const char* old_msg,
const char *calling_func, const char *calling_func,
const char *calling_file, const char *calling_file,
const unsigned int calling_line) const unsigned int calling_line)
{ {
DBUG_ASSERT(mutex == (pthread_mutex_t*) mysys_var->current_mutex); DBUG_ASSERT(mutex == mysys_var->current_mutex);
pthread_mutex_unlock(mutex); mysql_mutex_unlock(mutex);
mysql_mutex_lock(&mysys_var->mutex); mysql_mutex_lock(&mysys_var->mutex);
mysys_var->current_mutex= 0; mysys_var->current_mutex= NULL;
mysys_var->current_cond= 0; mysys_var->current_cond= NULL;
mysql_mutex_unlock(&mysys_var->mutex); mysql_mutex_unlock(&mysys_var->mutex);
DEBUG_SYNC(thd, "mdl_exit_cond"); DEBUG_SYNC(thd, "mdl_exit_cond");
...@@ -778,12 +778,12 @@ MDL_context::mdl_signal_type MDL_context::wait() ...@@ -778,12 +778,12 @@ MDL_context::mdl_signal_type MDL_context::wait()
st_my_thread_var *mysys_var= my_thread_var; st_my_thread_var *mysys_var= my_thread_var;
mdl_signal_type result; mdl_signal_type result;
pthread_mutex_lock(&m_signal_lock); mysql_mutex_lock(&m_signal_lock);
old_msg= MDL_ENTER_COND(m_thd, mysys_var, &m_signal_cond, &m_signal_lock); old_msg= MDL_ENTER_COND(m_thd, mysys_var, &m_signal_cond, &m_signal_lock);
while (! m_signal && !mysys_var->abort) while (! m_signal && !mysys_var->abort)
pthread_cond_wait(&m_signal_cond, &m_signal_lock); mysql_cond_wait(&m_signal_cond, &m_signal_lock);
result= m_signal; result= m_signal;
...@@ -800,14 +800,14 @@ MDL_context::mdl_signal_type MDL_context::timed_wait(ulong timeout) ...@@ -800,14 +800,14 @@ MDL_context::mdl_signal_type MDL_context::timed_wait(ulong timeout)
mdl_signal_type result; mdl_signal_type result;
st_my_thread_var *mysys_var= my_thread_var; st_my_thread_var *mysys_var= my_thread_var;
pthread_mutex_lock(&m_signal_lock); mysql_mutex_lock(&m_signal_lock);
old_msg= MDL_ENTER_COND(m_thd, mysys_var, &m_signal_cond, &m_signal_lock); old_msg= MDL_ENTER_COND(m_thd, mysys_var, &m_signal_cond, &m_signal_lock);
if (! m_signal) if (! m_signal)
{ {
set_timespec(abstime, timeout); set_timespec(abstime, timeout);
pthread_cond_timedwait(&m_signal_cond, &m_signal_lock, &abstime); mysql_cond_timedwait(&m_signal_cond, &m_signal_lock, &abstime);
} }
result= (m_signal != NO_WAKE_UP) ? m_signal : TIMEOUT_WAKE_UP; result= (m_signal != NO_WAKE_UP) ? m_signal : TIMEOUT_WAKE_UP;
......
...@@ -520,10 +520,10 @@ public: ...@@ -520,10 +520,10 @@ public:
*/ */
void awake(mdl_signal_type signal) void awake(mdl_signal_type signal)
{ {
pthread_mutex_lock(&m_signal_lock); mysql_mutex_lock(&m_signal_lock);
m_signal= signal; m_signal= signal;
pthread_cond_signal(&m_signal_cond); mysql_cond_signal(&m_signal_cond);
pthread_mutex_unlock(&m_signal_lock); mysql_mutex_unlock(&m_signal_lock);
} }
void init(THD *thd_arg) { m_thd= thd_arg; } void init(THD *thd_arg) { m_thd= thd_arg; }
...@@ -636,8 +636,8 @@ private: ...@@ -636,8 +636,8 @@ private:
notification by adding a ticket corresponding to the request notification by adding a ticket corresponding to the request
to an appropriate queue of waiters). to an appropriate queue of waiters).
*/ */
pthread_mutex_t m_signal_lock; mysql_mutex_t m_signal_lock;
pthread_cond_t m_signal_cond; mysql_cond_t m_signal_cond;
mdl_signal_type m_signal; mdl_signal_type m_signal;
private: private:
...@@ -675,9 +675,9 @@ private: ...@@ -675,9 +675,9 @@ private:
void wait_reset() void wait_reset()
{ {
pthread_mutex_lock(&m_signal_lock); mysql_mutex_lock(&m_signal_lock);
m_signal= NO_WAKE_UP; m_signal= NO_WAKE_UP;
pthread_mutex_unlock(&m_signal_lock); mysql_mutex_unlock(&m_signal_lock);
} }
mdl_signal_type wait(); mdl_signal_type wait();
...@@ -686,9 +686,9 @@ private: ...@@ -686,9 +686,9 @@ private:
mdl_signal_type peek_signal() mdl_signal_type peek_signal()
{ {
mdl_signal_type result; mdl_signal_type result;
pthread_mutex_lock(&m_signal_lock); mysql_mutex_lock(&m_signal_lock);
result= m_signal; result= m_signal;
pthread_mutex_unlock(&m_signal_lock); mysql_mutex_unlock(&m_signal_lock);
return result; return result;
} }
......
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