diff options
Diffstat (limited to 'sql/sql_class.h')
-rw-r--r-- | sql/sql_class.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/sql/sql_class.h b/sql/sql_class.h index 64fed055c80..59ac8ff0483 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -885,6 +885,12 @@ public: void close_active_vio(); #endif void awake(bool prepare_to_die); + /* + For enter_cond() / exit_cond() to work the mutex must be got before + enter_cond() (in 4.1 an assertion will soon ensure this); this mutex is + then released by exit_cond(). Use must be: + lock mutex; enter_cond(); your code; exit_cond(). + */ inline const char* enter_cond(pthread_cond_t *cond, pthread_mutex_t* mutex, const char* msg) { @@ -896,6 +902,13 @@ public: } inline void exit_cond(const char* old_msg) { + /* + Putting the mutex unlock in exit_cond() ensures that + mysys_var->current_mutex is always unlocked _before_ mysys_var->mutex is + locked (if that would not be the case, you'll get a deadlock if someone + does a THD::awake() on you). + */ + pthread_mutex_unlock(mysys_var->current_mutex); pthread_mutex_lock(&mysys_var->mutex); mysys_var->current_mutex = 0; mysys_var->current_cond = 0; |