diff options
author | Dmitry Shulga <Dmitry.Shulga@Sun.COM> | 2010-06-29 16:32:03 +0700 |
---|---|---|
committer | Dmitry Shulga <Dmitry.Shulga@Sun.COM> | 2010-06-29 16:32:03 +0700 |
commit | 48a74d7472d92915c12671d2b0563df5d44614b4 (patch) | |
tree | e7719a7a52654d8d2e904b0df66123387fdf3e81 /sql/sql_class.cc | |
parent | 8a2f3f4b5ed8778c00b6ad169aaad28a4eb6058c (diff) | |
download | mariadb-git-48a74d7472d92915c12671d2b0563df5d44614b4.tar.gz |
Fixed bug #51855. Race condition in XA START. If several threads
concurrently execute the statement XA START 'x', then mysqld
server could crash.
Diffstat (limited to 'sql/sql_class.cc')
-rw-r--r-- | sql/sql_class.cc | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 93aa6a8268c..99792f2b262 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -3365,9 +3365,13 @@ bool xid_cache_insert(XID *xid, enum xa_states xa_state) bool xid_cache_insert(XID_STATE *xid_state) { pthread_mutex_lock(&LOCK_xid_cache); - DBUG_ASSERT(hash_search(&xid_cache, xid_state->xid.key(), - xid_state->xid.key_length())==0); - my_bool res=my_hash_insert(&xid_cache, (uchar*)xid_state); + if (hash_search(&xid_cache, xid_state->xid.key(), xid_state->xid.key_length())) + { + pthread_mutex_unlock(&LOCK_xid_cache); + my_error(ER_XAER_DUPID, MYF(0)); + return TRUE; + } + my_bool res= my_hash_insert(&xid_cache, (uchar*)xid_state); pthread_mutex_unlock(&LOCK_xid_cache); return res; } |