summaryrefslogtreecommitdiff
path: root/mysys/thr_lock.c
diff options
context:
space:
mode:
authorAlexander Nozdrin <alik@sun.com>2009-10-13 13:42:38 +0400
committerAlexander Nozdrin <alik@sun.com>2009-10-13 13:42:38 +0400
commitc69629d269fcab948800a427eff587b68cd7cf34 (patch)
treee56ffd06670e5f719dc7c91ca477eb50aa578a24 /mysys/thr_lock.c
parenteddd727a3a3de0e27e921551263e18c0b558a8ca (diff)
parent85bb4aa09ee906c5cb8a3f7af8ff319e3a6c93b9 (diff)
downloadmariadb-git-c69629d269fcab948800a427eff587b68cd7cf34.tar.gz
Merge from mysql-5.1.
Diffstat (limited to 'mysys/thr_lock.c')
-rw-r--r--mysys/thr_lock.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c
index 31638ecee9a..0e0e93cf220 100644
--- a/mysys/thr_lock.c
+++ b/mysys/thr_lock.c
@@ -398,6 +398,28 @@ wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data,
my_bool can_deadlock= test(data->owner->info->n_cursors);
DBUG_ENTER("wait_for_lock");
+ /*
+ One can use this to signal when a thread is going to wait for a lock.
+ See debug_sync.cc.
+
+ Beware of waiting for a signal here. The lock has aquired its mutex.
+ While waiting on a signal here, the locking thread could not aquire
+ the mutex to release the lock. One could lock up the table
+ completely.
+
+ In detail it works so: When thr_lock() tries to acquire a table
+ lock, it locks the lock->mutex, checks if it can have the lock, and
+ if not, it calls wait_for_lock(). Here it unlocks the table lock
+ while waiting on a condition. The sync point is located before this
+ wait for condition. If we have a waiting action here, we hold the
+ the table locks mutex all the time. Any attempt to look at the table
+ lock by another thread blocks it immediately on lock->mutex. This
+ can easily become an unexpected and unobvious blockage. So be
+ warned: Do not request a WAIT_FOR action for the 'wait_for_lock'
+ sync point unless you really know what you do.
+ */
+ DEBUG_SYNC_C("wait_for_lock");
+
if (!in_wait_list)
{
(*wait->last)=data; /* Wait for lock */