List:Commits« Previous MessageNext Message »
From:Jonas Oreland Date:August 2 2008 10:13am
Subject:bzr commit into mysql-5.1-telco-6.4 branch
View as plain text  

commit 6a004c45de7eff711679e3294923f8c115964af8
Author: Jonas Oreland <jonas@stripped>
Date:   Sat Aug 2 12:13:42 2008 +0200

    ndb(mt) -
      1) Add assertion that no NdbCondition is created before NdbCondition_init
      2) Don't create condition variables (as fallback for futex) in initializer,
         but add init() method
---
 storage/ndb/src/common/portlib/NdbCondition.c |    4 ++++
 storage/ndb/src/kernel/vm/mt.cpp              |    7 +++++++
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/storage/ndb/src/common/portlib/NdbCondition.c b/storage/ndb/src/common/portlib/NdbCondition.c
index e0b6614..d9a9b27 100644
--- a/storage/ndb/src/common/portlib/NdbCondition.c
+++ b/storage/ndb/src/common/portlib/NdbCondition.c
@@ -26,6 +26,8 @@ struct NdbCondition
   pthread_cond_t cond;
 };
 
+
+static int init = 0;
 #ifdef HAVE_CLOCK_GETTIME
 static int clock_id = CLOCK_REALTIME;
 #endif
@@ -33,6 +35,7 @@ static int clock_id = CLOCK_REALTIME;
 void
 NdbCondition_Init()
 {
+  init = 1;
 #if defined HAVE_CLOCK_GETTIME && defined HAVE_PTHREAD_CONDATTR_SETCLOCK && \
     defined CLOCK_MONOTONIC
   
@@ -78,6 +81,7 @@ NdbCondition_Create(void)
   struct NdbCondition* tmpCond;
   int result;
   
+  assert(init);
   tmpCond = (struct NdbCondition*)NdbMem_Allocate(sizeof(struct NdbCondition));
   
   if (tmpCond == NULL)
diff --git a/storage/ndb/src/kernel/vm/mt.cpp b/storage/ndb/src/kernel/vm/mt.cpp
index 730d9d6..a92a311 100644
--- a/storage/ndb/src/kernel/vm/mt.cpp
+++ b/storage/ndb/src/kernel/vm/mt.cpp
@@ -114,6 +114,7 @@ struct thr_wait
     FS_SLEEPING = 1,
   };
   thr_wait() { xcng(&m_futex_state, FS_RUNNING);}
+  void init () {}
 };
 
 /**
@@ -177,6 +178,11 @@ struct thr_wait
   NdbMutex *m_mutex;
   NdbCondition *m_cond;
   thr_wait() {
+    m_mutex = 0;
+    m_cond = 0;
+  }
+
+  void init() {
     m_mutex = NdbMutex_Create();
     m_cond = NdbCondition_Create();
   }
@@ -1913,6 +1919,7 @@ update_sched_stats(thr_data *selfptr)
 static void
 init_thread(thr_data *selfptr, EmulatedJamBuffer *jam, Uint32 *watchDogCounter)
 {
+  selfptr->m_waiter.init();
   jam->theEmulatedJamIndex = 0;
   jam->theEmulatedJamBlockNumber = 0;
   memset(jam->theEmulatedJam, 0, sizeof(jam->theEmulatedJam));
Thread
bzr commit into mysql-5.1-telco-6.4 branch Jonas Oreland2 Aug