summaryrefslogtreecommitdiff
path: root/sql/sql_class.h
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2013-06-12 20:29:19 +0200
committerSergei Golubchik <sergii@pisem.net>2013-06-12 20:29:19 +0200
commitdacb3809a2a88e8562bf3021afafa490d37de166 (patch)
treec92482c652fd77c1bebf28e37f764305b3f02344 /sql/sql_class.h
parentf722b15dc23e6a0ca587553d35982e0936b1de9f (diff)
downloadmariadb-git-dacb3809a2a88e8562bf3021afafa490d37de166.tar.gz
MDEV-4422 SHOW PROCESSLIST reference to THD::db not protected against simultaneous updates
protect THD::db with THD::LOCK_thd_data
Diffstat (limited to 'sql/sql_class.h')
-rw-r--r--sql/sql_class.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 52acba682a2..b11e18777d5 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -1605,6 +1605,7 @@ public:
Protects THD data accessed from other threads:
- thd->query and thd->query_length (used by SHOW ENGINE
INNODB STATUS and SHOW PROCESSLIST
+ - thd->db and thd->db_length (used in SHOW PROCESSLIST)
- thd->mysys_var (used by KILL statement and shutdown).
Is locked when THD is deleted.
*/
@@ -2838,6 +2839,7 @@ public:
*/
bool set_db(const char *new_db, size_t new_db_len)
{
+ mysql_mutex_lock(&LOCK_thd_data);
/* Do not reallocate memory if current chunk is big enough. */
if (db && new_db && db_length >= new_db_len)
memcpy(db, new_db, new_db_len+1);
@@ -2850,6 +2852,7 @@ public:
db= NULL;
}
db_length= db ? new_db_len : 0;
+ mysql_mutex_unlock(&LOCK_thd_data);
return new_db && !db;
}
@@ -2866,8 +2869,13 @@ public:
*/
void reset_db(char *new_db, size_t new_db_len)
{
- db= new_db;
- db_length= new_db_len;
+ if (new_db != db || new_db_len != db_length)
+ {
+ mysql_mutex_lock(&LOCK_thd_data);
+ db= new_db;
+ db_length= new_db_len;
+ mysql_mutex_unlock(&LOCK_thd_data);
+ }
}
/*
Copy the current database to the argument. Use the current arena to