summaryrefslogtreecommitdiff
path: root/sql/event_scheduler.cc
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2013-01-31 09:48:19 +0100
committerSergei Golubchik <sergii@pisem.net>2013-01-31 09:48:19 +0100
commitab83952f293ea46c00e421c81b81a394c9cae2b4 (patch)
tree6a3e995bd1330828a0e988d896bca218863fc74c /sql/event_scheduler.cc
parent055b62f404ee0a0463ee8ff98a0e24c083b95f1d (diff)
parent5267af5e9e5e601d4f4b1ef40730da1e36d38d9d (diff)
downloadmariadb-git-ab83952f293ea46c00e421c81b81a394c9cae2b4.tar.gz
10.0-base merge
Diffstat (limited to 'sql/event_scheduler.cc')
-rw-r--r--sql/event_scheduler.cc17
1 files changed, 9 insertions, 8 deletions
diff --git a/sql/event_scheduler.cc b/sql/event_scheduler.cc
index c340384f068..ec96ca45a0e 100644
--- a/sql/event_scheduler.cc
+++ b/sql/event_scheduler.cc
@@ -153,8 +153,6 @@ void
deinit_event_thread(THD *thd)
{
thd->proc_info= "Clearing";
- DBUG_ASSERT(thd->net.buff != 0);
- net_end(&thd->net);
DBUG_PRINT("exit", ("Event thread finishing"));
mysql_mutex_lock(&LOCK_thread_count);
thread_count--;
@@ -182,12 +180,15 @@ deinit_event_thread(THD *thd)
void
pre_init_event_thread(THD* thd)
{
+ THD *orig_thd= current_thd;
DBUG_ENTER("pre_init_event_thread");
+
+ set_current_thd(thd);
thd->client_capabilities= 0;
thd->security_ctx->master_access= 0;
thd->security_ctx->db_access= 0;
thd->security_ctx->host_or_ip= (char*)my_localhost;
- my_net_init(&thd->net, NULL);
+ my_net_init(&thd->net, NULL, MYF(MY_THREAD_SPECIFIC));
thd->security_ctx->set_user((char*)"event_scheduler");
thd->net.read_timeout= slave_net_timeout;
thd->variables.option_bits|= OPTION_AUTO_IS_NULL;
@@ -207,6 +208,7 @@ pre_init_event_thread(THD* thd)
/* Do not use user-supplied timeout value for system threads. */
thd->variables.lock_wait_timeout= LONG_TIMEOUT;
+ set_current_thd(orig_thd);
DBUG_VOID_RETURN;
}
@@ -402,6 +404,7 @@ Event_scheduler::start()
ret= TRUE;
goto end;
}
+
pre_init_event_thread(new_thd);
new_thd->system_thread= SYSTEM_THREAD_EVENT_SCHEDULER;
new_thd->set_command(COM_DAEMON);
@@ -417,6 +420,7 @@ Event_scheduler::start()
new_thd->variables.tx_read_only= false;
new_thd->tx_read_only= false;
+ /* This should not be marked with MY_THREAD_SPECIFIC */
scheduler_param_value=
(struct scheduler_param *)my_malloc(sizeof(struct scheduler_param), MYF(0));
scheduler_param_value->thd= new_thd;
@@ -436,8 +440,6 @@ Event_scheduler::start()
ret= TRUE;
new_thd->proc_info= "Clearing";
- DBUG_ASSERT(new_thd->net.buff != 0);
- net_end(&new_thd->net);
mysql_mutex_lock(&LOCK_thread_count);
thread_count--;
dec_thread_running();
@@ -537,6 +539,7 @@ Event_scheduler::execute_top(Event_queue_element_for_exec *event_name)
pthread_t th;
int res= 0;
DBUG_ENTER("Event_scheduler::execute_top");
+
if (!(new_thd= new THD()))
goto error;
@@ -571,8 +574,6 @@ error:
if (new_thd)
{
new_thd->proc_info= "Clearing";
- DBUG_ASSERT(new_thd->net.buff != 0);
- net_end(&new_thd->net);
mysql_mutex_lock(&LOCK_thread_count);
thread_count--;
dec_thread_running();
@@ -676,7 +677,7 @@ Event_scheduler::stop()
*/
struct timespec top_time;
set_timespec(top_time, 2);
- COND_STATE_WAIT(thd, NULL, &stage_waiting_for_scheduler_to_stop);
+ COND_STATE_WAIT(thd, &top_time, &stage_waiting_for_scheduler_to_stop);
} while (state == STOPPING);
DBUG_PRINT("info", ("Scheduler thread has cleaned up. Set state to INIT"));
sql_print_information("Event Scheduler: Stopped");