diff options
author | kostja@bodhi.local <> | 2007-03-20 00:42:11 +0300 |
---|---|---|
committer | kostja@bodhi.local <> | 2007-03-20 00:42:11 +0300 |
commit | bdb10baec172fa2443f94b0f613a2c9d5e843017 (patch) | |
tree | 430ad1efea83b67994a7f31aab1a92c249366fb6 /sql/event_queue.cc | |
parent | e9fb4a686ff2d464e33902624d8425d379ef5016 (diff) | |
parent | 1812656d90f7d6d3db961500779c7ee8b8bea780 (diff) | |
download | mariadb-git-bdb10baec172fa2443f94b0f613a2c9d5e843017.tar.gz |
Merge bk-internal.mysql.com:/home/bk/mysql-5.1
into bodhi.local:/opt/local/work/mysql-5.1-runtime
Diffstat (limited to 'sql/event_queue.cc')
-rw-r--r-- | sql/event_queue.cc | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/sql/event_queue.cc b/sql/event_queue.cc index fb1653d6d8f..ef9dddf9195 100644 --- a/sql/event_queue.cc +++ b/sql/event_queue.cc @@ -65,8 +65,10 @@ struct event_queue_param static int event_queue_element_compare_q(void *vptr, byte* a, byte *b) { - return my_time_compare(&((Event_queue_element *)a)->execute_at, - &((Event_queue_element *)b)->execute_at); + my_time_t lhs = ((Event_queue_element *)a)->execute_at; + my_time_t rhs = ((Event_queue_element *)b)->execute_at; + + return (lhs < rhs ? -1 : (lhs > rhs ? 1 : 0)); } @@ -84,7 +86,7 @@ Event_queue::Event_queue() { mutex_last_unlocked_in_func= mutex_last_locked_in_func= mutex_last_attempted_lock_in_func= ""; - set_zero_time(&next_activation_at, MYSQL_TIMESTAMP_DATETIME); + next_activation_at= 0; } @@ -497,15 +499,11 @@ Event_queue::dbug_dump_queue(time_t now) DBUG_PRINT("info", ("exec_at: %lu starts: %lu ends: %lu execs_so_far: %u " "expr: %ld et.exec_at: %ld now: %ld " "(et.exec_at - now): %d if: %d", - (long) TIME_to_ulonglong_datetime(&et->execute_at), - (long) TIME_to_ulonglong_datetime(&et->starts), - (long) TIME_to_ulonglong_datetime(&et->ends), - et->execution_count, - (long) et->expression, - (long) (sec_since_epoch_TIME(&et->execute_at)), - (long) now, - (int) (sec_since_epoch_TIME(&et->execute_at) - now), - sec_since_epoch_TIME(&et->execute_at) <= now)); + (long) et->execute_at, (long) et->starts, + (long) et->ends, et->execution_count, + (long) et->expression, (long) et->execute_at, + (long) now, (int) (et->execute_at - now), + et->execute_at <= now)); } DBUG_VOID_RETURN; #endif @@ -534,7 +532,6 @@ Event_queue::get_top_for_execution_if_time(THD *thd, Event_queue_element_for_exec **event_name) { bool ret= FALSE; - struct timespec top_time; *event_name= NULL; DBUG_ENTER("Event_queue::get_top_for_execution_if_time"); @@ -553,7 +550,7 @@ Event_queue::get_top_for_execution_if_time(THD *thd, if (!queue.elements) { /* There are no events in the queue */ - set_zero_time(&next_activation_at, MYSQL_TIMESTAMP_DATETIME); + next_activation_at= 0; /* Wait on condition until signaled. Release LOCK_queue while waiting. */ cond_wait(thd, NULL, queue_empty_msg, SCHED_FUNC, __LINE__); @@ -565,16 +562,15 @@ Event_queue::get_top_for_execution_if_time(THD *thd, thd->end_time(); /* Get current time */ - time_t seconds_to_next_event= - sec_since_epoch_TIME(&top->execute_at) - thd->query_start(); next_activation_at= top->execute_at; - if (seconds_to_next_event > 0) + if (next_activation_at > thd->query_start()) { /* Not yet time for top event, wait on condition with time or until signaled. Release LOCK_queue while waiting. */ - set_timespec(top_time, seconds_to_next_event); + struct timespec top_time; + set_timespec(top_time, next_activation_at - thd->query_start()); cond_wait(thd, &top_time, queue_wait_msg, SCHED_FUNC, __LINE__); continue; @@ -752,10 +748,11 @@ Event_queue::dump_internal_status() printf("Last lock attempt at: %s:%u\n", mutex_last_attempted_lock_in_func, mutex_last_attempted_lock_at_line); printf("WOC : %s\n", waiting_on_cond? "YES":"NO"); + + TIME time; + my_tz_UTC->gmt_sec_to_TIME(&time, next_activation_at); printf("Next activation : %04d-%02d-%02d %02d:%02d:%02d\n", - next_activation_at.year, next_activation_at.month, - next_activation_at.day, next_activation_at.hour, - next_activation_at.minute, next_activation_at.second); + time.year, time.month, time.day, time.hour, time.minute, time.second); DBUG_VOID_RETURN; } |