List:Commits« Previous MessageNext Message »
From:Konstantin Osipov Date:January 20 2010 1:43pm
Subject:bzr push into mysql-5.6-next-mr branch (kostja:3060 to 3061) Bug#38924
Bug#46272
View as plain text  
 3061 Konstantin Osipov	2010-01-20
      Bug#46272/Bug#38924 review fixes in progress.
      Misc. fixes.

    modified:
      sql/mdl.cc
 3060 Konstantin Osipov	2010-01-20
      Bug#46272/Bug#38924 review fixes in progress.
      Introduce class MDL_map to hold all MDL locks
      taken in the server.

    modified:
      sql/mdl.cc
=== modified file 'sql/mdl.cc'
--- a/sql/mdl.cc	2010-01-20 12:30:49 +0000
+++ b/sql/mdl.cc	2010-01-20 13:43:34 +0000
@@ -31,9 +31,6 @@ static bool mdl_initialized= 0;
 class MDL_map
 {
 public:
-  pthread_mutex_t m_mutex;
-  HASH m_locks;
-
   void init();
   void destroy();
   MDL_lock *find(const MDL_key *key);
@@ -41,6 +38,11 @@ public:
   void remove(MDL_lock *lock);
 private:
   bool move_from_hash_to_lock_mutex(MDL_lock *lock);
+private:
+  /** All acquired locks in the server. */
+  HASH m_locks;
+  /* Protects access to m_locks hash. */
+  pthread_mutex_t m_mutex;
 };
 
 
@@ -360,12 +362,13 @@ bool MDL_map::move_from_hash_to_lock_mut
   if (unlikely(lock->m_is_destroyed))
   {
     /*
-      Object was released while we held no mutex, we need to release
-      it if no others hold references to it, our reference count
-      ensured that the object as such haven't got its memory released
-      yet. We can also safely check m_ref_usage and m_ref_release to each
-      other since the object is removed from the hash so no one will
-      be able to find it and increment m_ref_usage anymore.
+      Object was released while we held no mutex, we need to
+      release it if no others hold references to it, while our own
+      reference count ensured that the object as such haven't got
+      its memory released yet. We can also safely compare
+      m_ref_usage and m_ref_release since the object is no longer
+      present in the hash so no one will be able to find it and
+      increment m_ref_usage anymore.
     */
     uint ref_usage= lock->m_ref_usage;
     uint ref_release= lock->m_ref_release;
@@ -379,8 +382,9 @@ bool MDL_map::move_from_hash_to_lock_mut
 
 
 /**
-  Destroy MDL_lock object or delegate this resposibility to whatever thread
-  which will hold last outstanding reference to it,
+  Destroy MDL_lock object or delegate this responsibility to
+  whatever thread that holds the last outstanding reference to
+  it.
 */
 
 void MDL_map::remove(MDL_lock *lock)
@@ -414,9 +418,9 @@ void MDL_map::remove(MDL_lock *lock)
   ref_usage= lock->m_ref_usage;
   ref_release= lock->m_ref_release;
   pthread_mutex_unlock(&lock->m_mutex);
+  pthread_mutex_unlock(&m_mutex);
   if (ref_usage == ref_release)
     MDL_lock::destroy(lock);
-  pthread_mutex_unlock(&m_mutex);
 }
 
 
@@ -752,14 +756,15 @@ void MDL_global_lock::wake_up_waiters()
   }
 
   /*
-    There are no active locks. Wake up contexts waiting for global
-    shared lock (happens when INTENTION EXCLUSIVE lock is released).
-
-    We don't wake up contexts waiting for global shared lock if there
-    is active global shared lock since such situation is transient
-    and in it contexts marked as waiting for global shared lock must
-    be already woken up and simply have not managed to update lock
-    object yet.
+    If there are no active locks, wake up contexts waiting for
+    the global shared lock (happens when an INTENTION EXCLUSIVE
+    lock is released).
+
+    We don't wake up contexts waiting for the global shared lock
+    if there is an active global shared lock since such situation
+    is transient and in it contexts marked as waiting for global
+    shared lock must be already woken up and simply have not
+    managed to update lock object yet.
   */
   if (granted.is_empty() &&
       ! waiting_shared.is_empty())


Attachment: [text/bzr-bundle] bzr/kostja@sun.com-20100120134334-ibmbctthkj5w0r5j.bundle
Thread
bzr push into mysql-5.6-next-mr branch (kostja:3060 to 3061) Bug#38924Bug#46272Konstantin Osipov20 Jan