diff options
Diffstat (limited to 'sql/event_scheduler.cc')
-rw-r--r-- | sql/event_scheduler.cc | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/sql/event_scheduler.cc b/sql/event_scheduler.cc index 00d03e04b70..486b03fc58e 100644 --- a/sql/event_scheduler.cc +++ b/sql/event_scheduler.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2006 MySQL AB +/* Copyright (C) 2004-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -163,7 +163,7 @@ deinit_event_thread(THD *thd) /* - Performs pre- pthread_create() initialisation of THD. Do this + Performs pre- mysql_thread_create() initialisation of THD. Do this in the thread that will pass THD to the child thread. In the child thread call post_init_event_thread(). @@ -227,6 +227,9 @@ event_scheduler_thread(void *arg) bool res; thd->thread_stack= (char *)&thd; // remember where our stack is + + mysql_thread_set_psi_id(thd->thread_id); + res= post_init_event_thread(thd); DBUG_ENTER("event_scheduler_thread"); @@ -259,6 +262,8 @@ event_worker_thread(void *arg) thd= event->thd; + mysql_thread_set_psi_id(thd->thread_id); + Event_worker_thread worker_thread; worker_thread.run(thd, event); @@ -335,16 +340,17 @@ Event_scheduler::Event_scheduler(Event_queue *queue_arg) waiting_on_cond(FALSE), started_events(0) { - pthread_mutex_init(&LOCK_scheduler_state, MY_MUTEX_INIT_FAST); - pthread_cond_init(&COND_state, NULL); + mysql_mutex_init(key_event_scheduler_LOCK_scheduler_state, + &LOCK_scheduler_state, MY_MUTEX_INIT_FAST); + mysql_cond_init(key_event_scheduler_COND_state, &COND_state, NULL); } Event_scheduler::~Event_scheduler() { stop(); /* does nothing if not running */ - pthread_mutex_destroy(&LOCK_scheduler_state); - pthread_cond_destroy(&COND_state); + mysql_mutex_destroy(&LOCK_scheduler_state); + mysql_cond_destroy(&COND_state); } @@ -403,8 +409,9 @@ Event_scheduler::start() DBUG_PRINT("info", ("Setting state go RUNNING")); state= RUNNING; DBUG_PRINT("info", ("Forking new thread for scheduler. THD: 0x%lx", (long) new_thd)); - if (pthread_create(&th, &connection_attrib, event_scheduler_thread, - (void*)scheduler_param_value)) + if (mysql_thread_create(key_thread_event_scheduler, + &th, &connection_attrib, event_scheduler_thread, + (void*)scheduler_param_value)) { DBUG_PRINT("error", ("cannot create a new thread")); state= INITIALIZED; @@ -487,7 +494,7 @@ Event_scheduler::run(THD *thd) scheduler_thd= NULL; state= INITIALIZED; DBUG_PRINT("info", ("Signalling back to the stopper COND_state")); - pthread_cond_signal(&COND_state); + mysql_cond_signal(&COND_state); UNLOCK_DATA(); DBUG_RETURN(res); @@ -531,8 +538,9 @@ Event_scheduler::execute_top(Event_queue_element_for_exec *event_name) reasonable level. */ /* Major failure */ - if ((res= pthread_create(&th, &connection_attrib, event_worker_thread, - event_name))) + if ((res= mysql_thread_create(key_thread_event_worker, + &th, &connection_attrib, event_worker_thread, + event_name))) goto error; ++started_events; @@ -632,13 +640,13 @@ Event_scheduler::stop() DBUG_PRINT("info", ("Scheduler thread has id %lu", scheduler_thd->thread_id)); /* Lock from delete */ - pthread_mutex_lock(&scheduler_thd->LOCK_thd_data); + mysql_mutex_lock(&scheduler_thd->LOCK_thd_data); /* This will wake up the thread if it waits on Queue's conditional */ sql_print_information("Event Scheduler: Killing the scheduler thread, " "thread id %lu", scheduler_thd->thread_id); scheduler_thd->awake(THD::KILL_CONNECTION); - pthread_mutex_unlock(&scheduler_thd->LOCK_thd_data); + mysql_mutex_unlock(&scheduler_thd->LOCK_thd_data); /* thd could be 0x0, when shutting down */ sql_print_information("Event Scheduler: " @@ -693,7 +701,7 @@ Event_scheduler::lock_data(const char *func, uint line) { DBUG_ENTER("Event_scheduler::lock_data"); DBUG_PRINT("enter", ("func=%s line=%u", func, line)); - pthread_mutex_lock(&LOCK_scheduler_state); + mysql_mutex_lock(&LOCK_scheduler_state); mutex_last_locked_in_func= func; mutex_last_locked_at_line= line; mutex_scheduler_data_locked= TRUE; @@ -719,7 +727,7 @@ Event_scheduler::unlock_data(const char *func, uint line) mutex_last_unlocked_at_line= line; mutex_scheduler_data_locked= FALSE; mutex_last_unlocked_in_func= func; - pthread_mutex_unlock(&LOCK_scheduler_state); + mysql_mutex_unlock(&LOCK_scheduler_state); DBUG_VOID_RETURN; } @@ -750,9 +758,9 @@ Event_scheduler::cond_wait(THD *thd, struct timespec *abstime, const char* msg, DBUG_PRINT("info", ("pthread_cond_%swait", abstime? "timed":"")); if (!abstime) - pthread_cond_wait(&COND_state, &LOCK_scheduler_state); + mysql_cond_wait(&COND_state, &LOCK_scheduler_state); else - pthread_cond_timedwait(&COND_state, &LOCK_scheduler_state, abstime); + mysql_cond_timedwait(&COND_state, &LOCK_scheduler_state, abstime); if (thd) { /* |