Commit 642077ea authored by Marko Mäkelä's avatar Marko Mäkelä

srv_get_active_thread_type(): Remove a potential race condition.

Call trx_purge_state() only once, to avoid a race condition if the
value changes while the conditions are being evaluated.
parent 7128328d
......@@ -2013,13 +2013,18 @@ srv_get_active_thread_type(void)
srv_sys_mutex_exit();
if (ret == SRV_NONE && srv_shutdown_state != SRV_SHUTDOWN_NONE) {
/* Check only on shutdown. */
if (ret == SRV_NONE
&& srv_shutdown_state != SRV_SHUTDOWN_NONE
&& trx_purge_state() != PURGE_STATE_DISABLED
&& trx_purge_state() != PURGE_STATE_EXIT) {
switch (trx_purge_state()) {
case PURGE_STATE_INIT:
case PURGE_STATE_RUN:
case PURGE_STATE_STOP:
ret = SRV_PURGE;
break;
case PURGE_STATE_DISABLED:
case PURGE_STATE_EXIT:
break;
}
}
return(ret);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment