summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorIngo Struewing <ingo.struewing@sun.com>2009-10-01 15:54:11 +0200
committerIngo Struewing <ingo.struewing@sun.com>2009-10-01 15:54:11 +0200
commit1f37e3d834c9c1c1d6c43c1d78e2b6032a4b7ec8 (patch)
tree53c06177a77b7cbe951fe756258c14fa19a282bb /mysys
parent5f8bb5c507631a56a267f42972c809d51dacd84b (diff)
parent4d57b851a0335ac098d46dad5b9f698ff2cd3e43 (diff)
downloadmariadb-git-1f37e3d834c9c1c1d6c43c1d78e2b6032a4b7ec8.tar.gz
auto-merge
Diffstat (limited to 'mysys')
-rw-r--r--mysys/my_static.c8
-rw-r--r--mysys/thr_lock.c22
2 files changed, 30 insertions, 0 deletions
diff --git a/mysys/my_static.c b/mysys/my_static.c
index d0c20da828a..a21a3d11104 100644
--- a/mysys/my_static.c
+++ b/mysys/my_static.c
@@ -92,6 +92,14 @@ int (*error_handler_hook)(uint error,const char *str,myf MyFlags)=
int (*fatal_error_handler_hook)(uint error,const char *str,myf MyFlags)=
my_message_no_curses;
+#if defined(ENABLED_DEBUG_SYNC)
+/**
+ Global pointer to be set if callback function is defined
+ (e.g. in mysqld). See sql/debug_sync.cc.
+*/
+void (*debug_sync_C_callback_ptr)(const char *, size_t);
+#endif /* defined(ENABLED_DEBUG_SYNC) */
+
#ifdef __WIN__
/* from my_getsystime.c */
ulonglong query_performance_frequency, query_performance_offset;
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 */