List:Commits« Previous MessageNext Message »
From:msvensson Date:December 18 2006 12:11pm
Subject:bk commit into 5.1 tree (msvensson:1.2379)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of msvensson. When msvensson does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2006-12-18 12:11:22+01:00, msvensson@shellback. +1 -0
  Merge maint1:/data/localhome/msvensson/mysql-5.1-new-maint
  into  shellback.:C:/mysql/mysql-5.1-new-maint
  MERGE: 1.2370.1.1

  sql/event_queue.cc@stripped, 2006-12-18 12:11:18+01:00, msvensson@shellback. +0 -0
    SCCS merged
    MERGE: 1.20.1.1

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	msvensson
# Host:	shellback.
# Root:	C:/mysql/mysql-5.1-new-maint/RESYNC

--- 1.21/sql/event_queue.cc	2006-12-15 17:47:17 +01:00
+++ 1.22/sql/event_queue.cc	2006-12-18 12:11:18 +01:00
@@ -699,10 +699,7 @@
 
   RETURN VALUE
     FALSE  No error. If *job_data==NULL then top not elligible for execution.
-           Could be that there is no top. If abstime->tv_sec is set to value
-           greater than zero then use abstime with pthread_cond_timedwait().
-           If abstime->tv_sec is zero then sleep with pthread_cond_wait().
-           abstime->tv_nsec is always zero.
+           Could be that there is no top.
     TRUE   Error
     
 */
@@ -712,7 +709,6 @@
 {
   bool ret= FALSE;
   struct timespec top_time;
-  struct timespec *abstime;
   Event_queue_element *top= NULL;
   bool to_free= FALSE;
   bool to_drop= FALSE;
@@ -724,44 +720,40 @@
   {
     int res;
 
-    thd->end_time();
-    time_t now= thd->query_start();
-    abstime= NULL;
-
-    if (queue.elements)
-    {
-      top= ((Event_queue_element*) queue_element(&queue, 0));
-      set_timespec(top_time,
-                   sec_since_epoch_TIME(&top->execute_at) - now);
-
-      abstime= &top_time;
-    }
-
-    if (!abstime || get_timespec_sec(*abstime) > now)
-    {
-      const char *msg;
-      if (abstime)
-      {
-        next_activation_at= top->execute_at;
-        msg= queue_wait_msg;
-      }
-      else
-      {
-        set_zero_time(&next_activation_at, MYSQL_TIMESTAMP_DATETIME);
-        msg= queue_empty_msg;
-      }
-
-      cond_wait(thd, abstime, msg, SCHED_FUNC, __LINE__);
-      if (thd->killed)
-      {
-        DBUG_PRINT("info", ("thd->killed=%d", thd->killed));
-        goto end;
-      }
+    /* Break loop if thd has been killed */
+    if (thd->killed)
+    {
+      DBUG_PRINT("info", ("thd->killed=%d", thd->killed));
+      goto end;
+    }
+
+    if (!queue.elements)
+    {
+      /* There are no events in the queue */
+      set_zero_time(&next_activation_at, MYSQL_TIMESTAMP_DATETIME);
+
+      /* Wait on condition until signaled. Release LOCK_queue while waiting. */
+      cond_wait(thd, NULL, queue_empty_msg, SCHED_FUNC, __LINE__);
+
+      continue;
+    }
+
+    top= ((Event_queue_element*) queue_element(&queue, 0));
+
+    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)
+    {
       /*
-        The queue could have been emptied. Therefore it's safe to start from
-        the beginning. Moreover, this way we will get also the new top, if
-        the element at the top has been changed.
+        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);
+      cond_wait(thd, &top_time, queue_wait_msg, SCHED_FUNC, __LINE__);
+
       continue;
     }
 
@@ -803,7 +795,7 @@
     else
       queue_replaced(&queue);
 
-    dbug_dump_queue(now);
+    dbug_dump_queue(thd->query_start());
     break;
   }
 end:
@@ -816,8 +808,7 @@
   if (to_free)
     delete top;
 
-  DBUG_PRINT("info", ("returning %d  et_new: 0x%lx  get_timespec_sec(abstime): %ld ",
-             ret, (long) *job_data, abstime ? get_timespec_sec(*abstime) : 0));
+  DBUG_PRINT("info", ("returning %d  et_new: 0x%lx ", ret, (long) *job_data));
 
   if (*job_data)
     DBUG_PRINT("info", ("db: %s  name: %s  definer=%s", (*job_data)->dbname.str,

Thread
bk commit into 5.1 tree (msvensson:1.2379)msvensson18 Dec