List:Commits« Previous MessageNext Message »
From:jonas Date:February 4 2007 10:03pm
Subject:bk commit into 5.0 tree (jonas:1.2264)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of jonas. When jonas 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, 2007-02-04 23:03:14+01:00, jonas@eel.(none) +1 -0
  ndbmtd - handle time wrap (i.e live longer than 65s)

  ndb/src/kernel/vm/mt/mt.cpp@stripped, 2007-02-04 23:03:11+01:00, jonas@eel.(none) +42 -12
    handle time wrap

# 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:	jonas
# Host:	eel.(none)
# Root:	/home/jonas/src/50-atrt

--- 1.6/ndb/src/kernel/vm/mt/mt.cpp	2007-02-04 23:03:19 +01:00
+++ 1.7/ndb/src/kernel/vm/mt/mt.cpp	2007-02-04 23:03:19 +01:00
@@ -386,37 +386,66 @@
 
 static
 void
+handle_time_wrap(struct thr_data* selfptr)
+{
+  Uint32 i;
+  struct thr_tq * tq = &selfptr->m_tq;
+  Uint32 cnt0 = tq->m_cnt[0];
+  Uint32 cnt1 = tq->m_cnt[1];
+  Uint32 tmp0 = scan_queue(selfptr, cnt0, 32767, tq->m_short_queue);
+  Uint32 tmp1 = scan_queue(selfptr, cnt1, 32767, tq->m_long_queue);
+  cnt0 -= tmp0;
+  cnt1 -= tmp1;
+  tq->m_cnt[0] = cnt0;
+  tq->m_cnt[1] = cnt1;
+  for (i = 0; i<cnt0; i++)
+  {
+    assert((tq->m_short_queue[i] & 0xFFFF) > 32767);
+    tq->m_short_queue[i] -= 32767;
+  }
+  for (i = 0; i<cnt1; i++)
+  {
+    assert((tq->m_long_queue[i] & 0xFFFF) > 32767);
+    tq->m_long_queue[i] -= 32767;
+  }
+}
+
+static
+void
 scan_time_queues(struct thr_data* selfptr)
 {
   struct thr_tq * tq = &selfptr->m_tq;
   NDB_TICKS now = NdbTick_CurrentMillisecond();
   NDB_TICKS last = selfptr->m_time;
 
-  Uint32 end = tq->m_current_time;
-  Uint32 next = tq->m_next_timer;
+  Uint32 curr = tq->m_current_time;
   Uint32 cnt0 = tq->m_cnt[0];
   Uint32 cnt1 = tq->m_cnt[1];
 
   Uint64 diff = now - last;
-  if (diff > 0)
+  if (diff == 0)
+  {
+    return;
+  }
+  else if (diff > 0)
   {
     Uint32 step = (Uint32)((diff > 20) ? 20 : diff);
-    Uint32 next = (end + step) & 0xFFFF;
-    if (next <= end)
+    Uint32 end = (curr + step);
+    if (end >= 32767)
     {
-      ndbout_c("wrap %d -> %d", end, next);
-      abort();
+      handle_time_wrap(selfptr);
+      cnt0 = tq->m_cnt[0];
+      cnt1 = tq->m_cnt[1];
+      end -= 32767;
     }
-
-    end = (end + step) & 0xFFFF;
     
     Uint32 tmp0 = scan_queue(selfptr, cnt0, end, tq->m_short_queue);
     Uint32 tmp1 = scan_queue(selfptr, cnt1, end, tq->m_long_queue);
 
     tq->m_current_time = end;
     tq->m_cnt[0] = cnt0 - tmp0;
-    tq->m_cnt[1] = cnt1 - tmp1;    
-    selfptr->m_time = now;
+    tq->m_cnt[1] = cnt1 - tmp1;
+    selfptr->m_time = last + step;
     
     return;
   }
@@ -874,7 +903,8 @@
   
   for (i = 0; i<NO_OF_BLOCKS; i++)
     rep->m_thread[thr_no].m_blocks[i] = globalData.getBlock(i + MIN_BLOCK_NO);
-  
+
+  (rep->m_thread+thr_no)->m_time = NdbTick_CurrentMillisecond();
   thr_main(rep, thr_no);
 }
 
Thread
bk commit into 5.0 tree (jonas:1.2264)jonas4 Feb