diff options
author | Jan Lindström <jplindst@mariadb.org> | 2014-01-25 11:02:49 +0200 |
---|---|---|
committer | Jan Lindström <jplindst@mariadb.org> | 2014-01-25 11:02:49 +0200 |
commit | d43afb8828e358f9c3bb690d0fdcd88b0637f155 (patch) | |
tree | f977f3b5fa3c938183510750aecbea31bccc67ef /sql/mdl.cc | |
parent | d0f77b83611077344ff29db02ea5593c9da62537 (diff) | |
parent | 02765f4c614069ece1f30976848b6299ba6f24bd (diff) | |
download | mariadb-git-d43afb8828e358f9c3bb690d0fdcd88b0637f155.tar.gz |
Merge MariaDB-10.0.7 revision 3961.
Diffstat (limited to 'sql/mdl.cc')
-rw-r--r-- | sql/mdl.cc | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/sql/mdl.cc b/sql/mdl.cc index c74a3e964cb..2f00388a14b 100644 --- a/sql/mdl.cc +++ b/sql/mdl.cc @@ -170,6 +170,7 @@ private: I_P_List_counter> Lock_cache; Lock_cache m_unused_locks_cache; + friend int mdl_iterate(int (*)(MDL_ticket *, void *), void *); }; @@ -199,6 +200,7 @@ private: MDL_lock *m_global_lock; /** Pre-allocated MDL_lock object for COMMIT namespace. */ MDL_lock *m_commit_lock; + friend int mdl_iterate(int (*)(MDL_ticket *, void *), void *); }; @@ -718,6 +720,46 @@ void mdl_destroy() } +static inline int mdl_iterate_lock(MDL_lock *lock, + int (*callback)(MDL_ticket *ticket, void *arg), + void *arg) +{ + MDL_lock::Ticket_iterator ticket_it(lock->m_granted); + MDL_ticket *ticket; + int res= 0; + mysql_prlock_rdlock(&lock->m_rwlock); + while ((ticket= ticket_it++) && !(res= callback(ticket, arg))) /* no-op */; + mysql_prlock_unlock(&lock->m_rwlock); + return res; +} + + +int mdl_iterate(int (*callback)(MDL_ticket *ticket, void *arg), void *arg) +{ + uint i, j; + int res; + DBUG_ENTER("mdl_iterate"); + + if ((res= mdl_iterate_lock(mdl_locks.m_global_lock, callback, arg)) || + (res= mdl_iterate_lock(mdl_locks.m_commit_lock, callback, arg))) + DBUG_RETURN(res); + + for (i= 0; i < mdl_locks.m_partitions.elements(); i++) + { + MDL_map_partition *part= mdl_locks.m_partitions.at(i); + mysql_mutex_lock(&part->m_mutex); + for (j= 0; j < part->m_locks.records; j++) + { + if ((res= mdl_iterate_lock((MDL_lock*) my_hash_element(&part->m_locks, j), + callback, arg))) + break; + } + mysql_mutex_unlock(&part->m_mutex); + } + DBUG_RETURN(res); +} + + /** Initialize the container for all MDL locks. */ void MDL_map::init() |