summaryrefslogtreecommitdiff
path: root/sql/log.cc
diff options
context:
space:
mode:
authorunknown <guilhem@mysql.com>2004-07-30 00:53:25 +0200
committerunknown <guilhem@mysql.com>2004-07-30 00:53:25 +0200
commitd475643da872a78a8b9a4f806b768803959bbb69 (patch)
tree397ba8915bf684bd260adc0419a320e31f309c4a /sql/log.cc
parent382ff793bb52de384ce49074c61ce81fc2ce3236 (diff)
downloadmariadb-git-d475643da872a78a8b9a4f806b768803959bbb69.tar.gz
Avoiding a theoretically possible crash (pthread_mutex_lock(0)) which could (at least in POSIX Threads books)
happen on SMP machines, when a thread is going to wait on a condition and it is KILLed at the same time. Cleaning code a bit by adding a test in enter_cond() that we have the mutex (was already the case in all places where it's called except one which is fixed here). sql/log.cc: safe_mutex_assert_owner() is now in THD::enter_cond() sql/slave.cc: lock mutex before waiting on condition. sql/sql_class.cc: THD::awake(): before locking the mutex, let's test it's not zero; in theory indeed, the killer thread may see current_cond non-zero and current_mutex zero (order of assignments is not guaranteed by POSIX). A comment noting that there is still a small chance a KILL does not work and needs being re-issued. sql/sql_class.h: Assert in enter_cond() that we have the mutex. It is already the case in all places where we call enter_cond(), so better ensure it there.
Diffstat (limited to 'sql/log.cc')
-rw-r--r--sql/log.cc1
1 files changed, 0 insertions, 1 deletions
diff --git a/sql/log.cc b/sql/log.cc
index 559d30f28ba..a0e2196cc59 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -1544,7 +1544,6 @@ bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length,
void MYSQL_LOG:: wait_for_update(THD* thd, bool master_or_slave)
{
- safe_mutex_assert_owner(&LOCK_log);
const char* old_msg = thd->enter_cond(&update_cond, &LOCK_log,
master_or_slave ?
"Has read all relay log; waiting for \