#At file:///home/msvensson/mysql/6.4/
3046 Magnus Svensson 2008-11-06 [merge]
Merge
modified:
storage/ndb/include/portlib/NdbThread.h
storage/ndb/include/transporter/TransporterRegistry.hpp
storage/ndb/include/util/SocketServer.hpp
storage/ndb/src/common/portlib/NdbThread.c
storage/ndb/src/common/transporter/TransporterRegistry.cpp
storage/ndb/src/common/util/SocketServer.cpp
storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp
storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp
storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp
storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp
storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp
storage/ndb/src/kernel/main.cpp
storage/ndb/src/kernel/vm/Configuration.cpp
storage/ndb/src/kernel/vm/Configuration.hpp
storage/ndb/src/kernel/vm/DynArr256.cpp
storage/ndb/src/kernel/vm/WatchDog.cpp
storage/ndb/src/kernel/vm/WatchDog.hpp
storage/ndb/src/ndbapi/TransporterFacade.cpp
storage/ndb/test/ndbapi/testMgm.cpp
storage/ndb/test/ndbapi/testNodeRestart.cpp
storage/ndb/test/ndbapi/testScanFilter.cpp
storage/ndb/test/ndbapi/test_event_merge.cpp
=== modified file 'storage/ndb/include/portlib/NdbThread.h'
--- a/storage/ndb/include/portlib/NdbThread.h 2008-03-28 09:26:17 +0000
+++ b/storage/ndb/include/portlib/NdbThread.h 2008-11-06 10:17:49 +0000
@@ -41,46 +41,6 @@ typedef void* (NDB_THREAD_FUNC)(void*);
typedef void* NDB_THREAD_ARG;
typedef size_t NDB_THREAD_STACKSIZE;
-#ifdef HAVE_LINUX_SCHEDULING
- typedef pid_t NDB_TID_TYPE;
-#else
-#ifdef HAVE_SOLARIS_AFFINITY
- typedef id_t NDB_TID_TYPE;
-#else
- typedef int NDB_TID_TYPE;
-#endif
-#endif
-
-#ifdef HAVE_LINUX_SCHEDULING
- typedef pid_t NDB_THAND_TYPE;
-#else
-#ifdef HAVE_PTHREAD_SELF
- typedef pthread_t NDB_THAND_TYPE;
-#else
- typedef int NDB_THAND_TYPE;
-#endif
-#endif
-
-/**
- * Three functions that are used in conjunctions with SocketClient
- * threads and SocketServer threads. In the NDB kernel they are
- * used to set real-time properties and lock threads to CPU's. In
- * the NDB API they are dummy subroutines.
- * ndb_thread_add_thread_id is used before starting run method in thread.
- * ndb_thread_remove_thread_id is called immediately after returning from
- * run-method in thread.
- * ndb_thread_fill_thread_object is called before calling
- * ndb_thread_add_thread_id to prepare parameters.
- */
-void*
-ndb_thread_add_thread_id(void *param);
-
-void*
-ndb_thread_remove_thread_id(void *param);
-
-void
-ndb_thread_fill_thread_object(void *param, uint *len, my_bool server);
-
struct NdbThread;
/*
@@ -101,22 +61,17 @@ void NdbThread_set_shm_sigmask(my_bool b
* * returnvalue: pointer to the created thread
*/
struct NdbThread* NdbThread_Create(NDB_THREAD_FUNC *p_thread_func,
- NDB_THREAD_ARG *p_thread_arg,
- const NDB_THREAD_STACKSIZE thread_stack_size,
- const char* p_thread_name,
- NDB_THREAD_PRIO thread_prio);
-
-struct NdbThread* NdbThread_CreateWithFunc(NDB_THREAD_FUNC *p_thread_func,
- NDB_THREAD_ARG *p_thread_arg,
- const NDB_THREAD_STACKSIZE thread_stack_size,
- const char* p_thread_name,
- NDB_THREAD_PRIO thread_prio,
- NDB_THREAD_FUNC *start_func,
- NDB_THREAD_ARG start_obj,
- size_t start_obj_len,
- NDB_THREAD_FUNC *end_func,
- NDB_THREAD_ARG end_obj,
- size_t end_obj_len);
+ NDB_THREAD_ARG *p_thread_arg,
+ const NDB_THREAD_STACKSIZE thread_stack_size,
+ const char* p_thread_name,
+ NDB_THREAD_PRIO thread_prio);
+
+
+/**
+ * Create a thread-object for "main" that can be used with
+ * other NdbThread_*-functions
+ */
+struct NdbThread* NdbThread_CreateObject(const char * name);
/**
* Destroy a thread
@@ -125,7 +80,6 @@ struct NdbThread* NdbThread_CreateWithFu
*
*/
void NdbThread_Destroy(struct NdbThread** p_thread);
-
/**
* Waitfor a thread, suspend the execution of the calling thread
@@ -152,25 +106,21 @@ void NdbThread_Exit(void *status);
int NdbThread_SetConcurrencyLevel(int level);
/**
- * Get thread id
- */
-NDB_TID_TYPE NdbThread_getThreadId();
-
-/**
- * Get thread handle
+ * Get "Tid" for thread
+ * should only be used for printing etc...
+ * return -1, if not supported on platform
*/
-NDB_THAND_TYPE NdbThread_getThreadHandle();
+int NdbThread_GetTid(struct NdbThread*);
/**
- * Set Scheduler for pid
+ * Set Scheduler for thread
*/
-int NdbThread_SetScheduler(NDB_THAND_TYPE threadHandle, my_bool rt_prio,
- my_bool high_prio);
+int NdbThread_SetScheduler(struct NdbThread*, my_bool rt_prio, my_bool high_prio);
/**
* Lock Thread to CPU
*/
-int NdbThread_LockCPU(NDB_TID_TYPE threadId, Uint32 cpu_id);
+int NdbThread_LockCPU(struct NdbThread*, Uint32 cpu);
/**
* Fetch and set thread-local storage entry.
=== modified file 'storage/ndb/include/transporter/TransporterRegistry.hpp'
--- a/storage/ndb/include/transporter/TransporterRegistry.hpp 2008-10-27 17:56:57 +0000
+++ b/storage/ndb/include/transporter/TransporterRegistry.hpp 2008-11-06 10:17:49 +0000
@@ -152,7 +152,7 @@ public:
virtual ~TransporterRegistry();
bool start_service(SocketServer& server);
- bool start_clients();
+ struct NdbThread* start_clients();
bool stop_clients();
void start_clients_thread();
void update_connections();
=== modified file 'storage/ndb/include/util/SocketServer.hpp'
--- a/storage/ndb/include/util/SocketServer.hpp 2008-08-21 06:32:09 +0000
+++ b/storage/ndb/include/util/SocketServer.hpp 2008-11-06 10:17:49 +0000
@@ -99,7 +99,7 @@ public:
/**
* start/stop the server
*/
- void startServer();
+ struct NdbThread* startServer();
void stopServer();
/**
=== modified file 'storage/ndb/src/common/portlib/NdbThread.c'
--- a/storage/ndb/src/common/portlib/NdbThread.c 2008-11-05 09:04:43 +0000
+++ b/storage/ndb/src/common/portlib/NdbThread.c 2008-11-06 10:17:49 +0000
@@ -24,12 +24,10 @@
#define _GNU_SOURCE
#endif
#include <sys/types.h>
-#include <sys/syscall.h>
#include <unistd.h>
#include <sched.h>
-#endif
-
-#ifdef HAVE_SOLARIS_AFFINITY
+#include <sys/syscall.h>],
+#elif defined HAVE_SOLARIS_AFFINITY
#include <sys/types.h>
#include <sys/lwp.h>
#include <sys/processor.h>
@@ -51,14 +49,14 @@ int g_ndb_shm_signum= 0;
struct NdbThread
{
pthread_t thread;
+#if defined HAVE_SOLARIS_AFFINITY
+ id_t tid;
+#elif defined HAVE_LINUX_SCHEDULING
+ pid_t tid;
+#endif
char thread_name[MAX_THREAD_NAME];
NDB_THREAD_FUNC * func;
void * object;
- NDB_THREAD_FUNC *start_func;
- NDB_THREAD_FUNC *end_func;
- my_bool same_start_end_object;
- char start_object[THREAD_CONTAINER_SIZE];
- char end_object[THREAD_CONTAINER_SIZE];
};
#ifdef NDB_SHM_TRANSPORTER
@@ -80,6 +78,36 @@ void NdbThread_set_shm_sigmask(my_bool b
}
#endif
+static
+void
+settid(struct NdbThread * thr)
+{
+#if defined HAVE_SOLARIS_AFFINITY
+ thr->tid = _lwp_self();
+#elif defined HAVE_LINUX_SCHEDULING
+ thr->tid = syscall(SYS_gettid);
+ if (thr->tid == (pid_t)-1)
+ {
+ /*
+ This extra check is from suggestion by Kristian Nielsen
+ to handle cases when running binaries on LinuxThreads
+ compiled with NPTL threads
+ */
+ thr->tid = getpid();
+ }
+#endif
+}
+
+int
+NdbThread_GetTid(struct NdbThread* thr)
+{
+#if defined HAVE_SOLARIS_AFFINITY
+ return (int)thr->tid;
+#elif defined HAVE_LINUX_SCHEDULING
+ return (int)thr->tid;
+#endif
+ return -1;
+}
static
void*
@@ -90,7 +118,6 @@ ndb_thread_wrapper(void* _ss){
#ifdef NDB_SHM_TRANSPORTER
NdbThread_set_shm_sigmask(TRUE);
#endif
-#ifndef NDB_WIN32
{
/**
* Block all signals to thread by default
@@ -100,21 +127,12 @@ ndb_thread_wrapper(void* _ss){
sigfillset(&mask);
pthread_sigmask(SIG_BLOCK, &mask, 0);
}
-#endif
-
+
{
void *ret;
struct NdbThread * ss = (struct NdbThread *)_ss;
- if (ss->start_func)
- (*ss->start_func)(ss->start_object);
+ settid(ss);
ret= (* ss->func)(ss->object);
- if (ss->end_func)
- {
- if (ss->same_start_end_object)
- (*ss->end_func)(ss->start_object);
- else
- (*ss->end_func)(ss->end_object);
- }
DBUG_POP();
NdbThread_Exit(ret);
}
@@ -124,33 +142,47 @@ ndb_thread_wrapper(void* _ss){
}
-struct NdbThread* NdbThread_Create(NDB_THREAD_FUNC *p_thread_func,
- NDB_THREAD_ARG *p_thread_arg,
- const NDB_THREAD_STACKSIZE _thread_stack_size,
- const char* p_thread_name,
- NDB_THREAD_PRIO thread_prio)
-{
- return NdbThread_CreateWithFunc(p_thread_func, p_thread_arg, _thread_stack_size,
- p_thread_name, thread_prio,
- NULL, NULL, 0, NULL, NULL, 0);
-}
-
-struct NdbThread* NdbThread_CreateWithFunc(NDB_THREAD_FUNC *p_thread_func,
- NDB_THREAD_ARG *p_thread_arg,
- const NDB_THREAD_STACKSIZE _thread_stack_size,
- const char* p_thread_name,
- NDB_THREAD_PRIO thread_prio,
- NDB_THREAD_FUNC *start_func,
- NDB_THREAD_ARG start_obj,
- size_t start_obj_len,
- NDB_THREAD_FUNC *end_func,
- NDB_THREAD_ARG end_obj,
- size_t end_obj_len)
+struct NdbThread*
+NdbThread_CreateObject(const char * name)
+{
+ struct NdbThread* tmpThread;
+ DBUG_ENTER("NdbThread_Create");
+
+ tmpThread = (struct NdbThread*)NdbMem_Allocate(sizeof(struct NdbThread));
+ if (tmpThread == NULL)
+ DBUG_RETURN(NULL);
+
+ bzero(tmpThread, sizeof(* tmpThread));
+ if (name)
+ {
+ strnmov(tmpThread->thread_name, name, sizeof(tmpThread->thread_name));
+ }
+ else
+ {
+ strnmov(tmpThread->thread_name, "main", sizeof(tmpThread->thread_name));
+ }
+
+#ifdef HAVE_PTHREAD_SELF
+ tmpThread->thread = pthread_self();
+#elif defined HAVE_GETPID
+ tmpThread->thread = getpid();
+#endif
+ settid(tmpThread);
+
+ return tmpThread;
+}
+
+struct NdbThread*
+NdbThread_Create(NDB_THREAD_FUNC *p_thread_func,
+ NDB_THREAD_ARG *p_thread_arg,
+ const NDB_THREAD_STACKSIZE _stack_size,
+ const char* p_thread_name,
+ NDB_THREAD_PRIO thread_prio)
{
struct NdbThread* tmpThread;
int result;
pthread_attr_t thread_attr;
- NDB_THREAD_STACKSIZE thread_stack_size= _thread_stack_size * SIZEOF_CHARP/4;
+ NDB_THREAD_STACKSIZE thread_stack_size= _stack_size * SIZEOF_CHARP/4;
DBUG_ENTER("NdbThread_Create");
@@ -167,15 +199,6 @@ struct NdbThread* NdbThread_CreateWithFu
strnmov(tmpThread->thread_name,p_thread_name,sizeof(tmpThread->thread_name));
- tmpThread->start_func = start_func;
- memcpy(tmpThread->start_object, start_obj, start_obj_len);
- tmpThread->end_func = end_func;
- memcpy(tmpThread->end_object, end_obj, end_obj_len);
- if (start_obj == end_obj)
- tmpThread->same_start_end_object = TRUE;
- else
- tmpThread->same_start_end_object = FALSE;
-
pthread_attr_init(&thread_attr);
#ifdef PTHREAD_STACK_MIN
if (thread_stack_size < PTHREAD_STACK_MIN)
@@ -253,49 +276,6 @@ int NdbThread_SetConcurrencyLevel(int le
#endif
}
-NDB_TID_TYPE
-NdbThread_getThreadId()
-{
-#ifdef HAVE_LINUX_SCHEDULING
- pid_t tid = syscall(SYS_gettid);
- if (tid == (pid_t)-1)
- {
- /*
- This extra check is from suggestion by Kristian Nielsen
- to handle cases when running binaries on LinuxThreads
- compiled with NPTL threads
- */
- tid = getpid();
- }
- return tid;
-#else
-#ifdef HAVE_SOLARIS_AFFINITY
- id_t tid;
- tid = _lwp_self();
- return tid;
-#else
- return 0;
-#endif
-#endif
-}
-
-NDB_THAND_TYPE
-NdbThread_getThreadHandle()
-{
-#ifdef HAVE_LINUX_SCHEDULING
- pid_t tid = syscall(SYS_gettid);
- if (tid == (pid_t)-1)
- tid = getpid();
- return tid;
-#else
-#ifdef HAVE_PTHREAD_SELF
- return pthread_self();
-#else
- return 0;
-#endif
-#endif
-}
-
static int
get_max_prio(int policy)
{
@@ -353,12 +333,12 @@ get_prio(my_bool rt_prio, my_bool high_p
}
int
-NdbThread_SetScheduler(NDB_THAND_TYPE threadHandle, my_bool rt_prio,
+NdbThread_SetScheduler(struct NdbThread* pThread,
+ my_bool rt_prio,
my_bool high_prio)
{
- int error_no= 0;
-#ifdef HAVE_LINUX_SCHEDULING
- int policy, prio;
+ int policy, prio, error_no= 0;
+#if defined HAVE_LINUX_SCHEDULING
int ret;
struct sched_param loc_sched_param;
if (rt_prio)
@@ -371,14 +351,12 @@ NdbThread_SetScheduler(NDB_THAND_TYPE th
policy = SCHED_OTHER;
prio = 0;
}
- memset((char*)&loc_sched_param, sizeof(loc_sched_param), 0);
+ bzero(&loc_sched_param, sizeof(loc_sched_param));
loc_sched_param.sched_priority = prio;
- ret= sched_setscheduler(threadHandle, policy, &loc_sched_param);
+ ret= sched_setscheduler(pThread->tid, policy, &loc_sched_param);
if (ret)
error_no= errno;
-#else
-#ifdef HAVE_PTHREAD_SET_SCHEDPARAM
- int policy, prio;
+#elif defined HAVE_PTHREAD_SET_SCHEDPARAM
/*
This variant is POSIX compliant so should be useful on most
Operating Systems supporting real-time scheduling.
@@ -395,21 +373,24 @@ NdbThread_SetScheduler(NDB_THAND_TYPE th
policy = SCHED_OTHER;
prio = 0;
}
- memset((char*)&loc_sched_param, sizeof(loc_sched_param), 0);
+ bzero(&loc_sched_param, sizeof(loc_sched_param));
loc_sched_param.sched_priority = prio;
- ret= pthread_setschedparam(threadHandle, policy, &loc_sched_param);
+ ret= pthread_setschedparam(pThread->thread, policy, &loc_sched_param);
if (ret)
error_no= errno;
+#else
+ error_no = ENOSYS;
#endif
-#endif
+
return error_no;
}
int
-NdbThread_LockCPU(NDB_TID_TYPE threadId, Uint32 cpu_id)
+NdbThread_LockCPU(struct NdbThread* pThread, Uint32 cpu_id)
{
- int error_no= 0;
-#ifdef HAVE_LINUX_SCHEDULING
+ int error_no = 0;
+#if defined HAVE_LINUX_SCHEDULING
+
/*
On recent Linux versions the ability to set processor
affinity is available through the sched_setaffinity call.
@@ -424,12 +405,10 @@ NdbThread_LockCPU(NDB_TID_TYPE threadId,
cpu_set_t cpu_set;
CPU_ZERO(&cpu_set);
CPU_SET(cpu_id, &cpu_set);
- ret= sched_setaffinity(threadId, sizeof(ulong),
- (const cpu_set_t *)&cpu_set);
+ ret= sched_setaffinity(pThread->tid, sizeof(cpu_set), &cpu_set);
if (ret)
- error_no= errno;
-#else
-#ifdef HAVE_SOLARIS_AFFINITY
+ error_no = errno;
+#elif defined HAVE_SOLARIS_AFFINITY
/*
Solaris have a number of versions to lock threads to CPU's.
We'll use the processor_bind interface since we only work
@@ -438,21 +417,11 @@ NdbThread_LockCPU(NDB_TID_TYPE threadId,
is the LWP id.
*/
int ret;
- ret= processor_bind(P_LWPID, threadId, cpu_id, NULL);
+ ret= processor_bind(P_LWPID, pThread->tid, cpu_id, NULL);
if (ret)
error_no= errno;
#else
-#ifdef WIN32
- /*
- Windows can currently as far I found out only lock processes
- to CPU's, thus it cannot be used to support the desirable
- feture here. So we ignore the call on Windows for the moment.
- */
- return error_no;
-#else
- return error_no;
-#endif
-#endif
+ error_no = ENOSYS;
#endif
return error_no;
}
=== modified file 'storage/ndb/src/common/transporter/TransporterRegistry.cpp'
--- a/storage/ndb/src/common/transporter/TransporterRegistry.cpp 2008-10-27 17:56:57 +0000
+++ b/storage/ndb/src/common/transporter/TransporterRegistry.cpp 2008-11-06 10:17:49 +0000
@@ -1543,30 +1543,20 @@ TransporterRegistry::start_clients_threa
DBUG_VOID_RETURN;
}
-bool
+struct NdbThread*
TransporterRegistry::start_clients()
{
- char thread_object[THREAD_CONTAINER_SIZE];
- uint len;
-
m_run_start_clients_thread= true;
- ndb_thread_fill_thread_object((void*)thread_object, &len, FALSE);
- m_start_clients_thread= NdbThread_CreateWithFunc(run_start_clients_C,
+ m_start_clients_thread= NdbThread_Create(run_start_clients_C,
(void**)this,
32768,
"ndb_start_clients",
- NDB_THREAD_PRIO_LOW,
- ndb_thread_add_thread_id,
- thread_object,
- len,
- ndb_thread_remove_thread_id,
- thread_object,
- len);
- if (m_start_clients_thread == 0) {
+ NDB_THREAD_PRIO_LOW);
+ if (m_start_clients_thread == 0)
+ {
m_run_start_clients_thread= false;
- return false;
}
- return true;
+ return m_start_clients_thread;
}
bool
=== modified file 'storage/ndb/src/common/util/SocketServer.cpp'
--- a/storage/ndb/src/common/util/SocketServer.cpp 2008-09-03 08:05:38 +0000
+++ b/storage/ndb/src/common/util/SocketServer.cpp 2008-11-06 10:17:49 +0000
@@ -224,28 +224,20 @@ socketServerThread_C(void* _ss){
return 0;
}
-void
+struct NdbThread*
SocketServer::startServer()
{
- char thread_object[THREAD_CONTAINER_SIZE];
- uint len;
-
m_threadLock.lock();
- if(m_thread == 0 && m_stopThread == false){
- ndb_thread_fill_thread_object((void*)thread_object, &len, TRUE);
- m_thread = NdbThread_CreateWithFunc(socketServerThread_C,
+ if(m_thread == 0 && m_stopThread == false)
+ {
+ m_thread = NdbThread_Create(socketServerThread_C,
(void**)this,
32768,
"NdbSockServ",
- NDB_THREAD_PRIO_LOW,
- ndb_thread_add_thread_id,
- thread_object,
- len,
- ndb_thread_remove_thread_id,
- thread_object,
- len);
+ NDB_THREAD_PRIO_LOW);
}
m_threadLock.unlock();
+ return m_thread;
}
void
=== modified file 'storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp'
--- a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp 2008-11-05 10:56:57 +0000
+++ b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp 2008-11-06 11:31:51 +0000
@@ -4129,6 +4129,10 @@ void Dbdict::send_nf_complete_rep(Signal
NdbNodeBitmask tmp;
tmp.assign(NdbNodeBitmask::Size, theFailedNodes);
+ NodeRecordPtr ownNodePtr;
+ c_nodes.getPtr(ownNodePtr, getOwnNodeId());
+ ownNodePtr.p->nodeState = NodeRecord::NDB_NODE_ALIVE; // reset take-over
+
for(unsigned i = 1; i < MAX_NDB_NODES; i++) {
jam();
if(tmp.get(i)) {
@@ -25129,7 +25133,6 @@ send_node_fail_rep:
*/
NodeFailRep * const nodeFailRep = (NodeFailRep *)&signal->theData[0];
*nodeFailRep = ownNodePtr.p->nodeFailRep;
- ownNodePtr.p->nodeState = NodeRecord::NDB_NODE_ALIVE;
send_nf_complete_rep(signal);
}
}
=== modified file 'storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp'
--- a/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp 2008-10-29 09:42:21 +0000
+++ b/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp 2008-11-03 08:38:27 +0000
@@ -14132,14 +14132,14 @@ void Dbdih::makeNodeGroups(Uint32 nodeAr
{
NodeGroupRecordPtr NGPtr;
NodeRecordPtr mngNodeptr;
- Uint32 i, j;
+ Uint32 j;
/**-----------------------------------------------------------------------
* ASSIGN ALL ACTIVE NODES INTO NODE GROUPS. HOT SPARE NODES ARE ASSIGNED
* TO NODE GROUP ZNIL
*-----------------------------------------------------------------------*/
cnoOfNodeGroups = 0;
- for (i = 0; nodeArray[i] != RNIL; i++)
+ for (Uint32 i = 0; nodeArray[i] != RNIL; i++)
{
jam();
mngNodeptr.i = nodeArray[i];
@@ -14171,7 +14171,7 @@ void Dbdih::makeNodeGroups(Uint32 nodeAr
break;
}
- for (i = 0; nodeArray[i] != RNIL; i++)
+ for (Uint32 i = 0; nodeArray[i] != RNIL; i++)
{
jam();
mngNodeptr.i = nodeArray[i];
@@ -14225,14 +14225,14 @@ void Dbdih::makeNodeGroups(Uint32 nodeAr
/**
* Init sysfile
*/
- for(i = 0; i < MAX_NDB_NODES; i++)
+ for(Uint32 i = 0; i < MAX_NDB_NODES; i++)
{
jam();
Sysfile::setNodeGroup(i, SYSFILE->nodeGroups, NO_NODE_GROUP_ID);
Sysfile::setNodeStatus(i, SYSFILE->nodeStatus,Sysfile::NS_NotDefined);
}
- for (i = 0; nodeArray[i] != RNIL; i++)
+ for (Uint32 i = 0; nodeArray[i] != RNIL; i++)
{
jam();
Uint32 nodeId = mngNodeptr.i = nodeArray[i];
@@ -14266,7 +14266,7 @@ void Dbdih::makeNodeGroups(Uint32 nodeAr
mngNodeptr.p->activeStatus);
}
- for (i = 0; i<cnoOfNodeGroups; i++)
+ for (Uint32 i = 0; i<cnoOfNodeGroups; i++)
{
jam();
bool alive = false;
@@ -14283,18 +14283,18 @@ void Dbdih::makeNodeGroups(Uint32 nodeAr
alive = true;
break;
}
- }
- if (!alive)
- {
- char buf[255];
- BaseString::snprintf
- (buf, sizeof(buf),
- "Illegal initial start, no alive node in nodegroup %u", i);
- progError(__LINE__,
- NDBD_EXIT_INSUFFICENT_NODES,
- buf);
-
+ if (!alive)
+ {
+ char buf[255];
+ BaseString::snprintf
+ (buf, sizeof(buf),
+ "Illegal initial start, no alive node in nodegroup %u", i);
+ progError(__LINE__,
+ NDBD_EXIT_INSUFFICENT_NODES,
+ buf);
+
+ }
}
}
}//Dbdih::makeNodeGroups()
=== modified file 'storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp'
--- a/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp 2008-10-21 13:20:59 +0000
+++ b/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp 2008-11-06 10:17:49 +0000
@@ -60,7 +60,7 @@ AsyncFile::AsyncFile(SimulatedBlock& fs)
m_auto_sync_freq = 0;
}
-void
+struct NdbThread*
AsyncFile::doStart()
{
// Stacksize for filesystem threads
@@ -68,7 +68,6 @@ AsyncFile::doStart()
const NDB_THREAD_STACKSIZE stackSize = 8192;
char buf[16];
- struct ThreadContainer container;
numAsyncFiles++;
BaseString::snprintf(buf, sizeof(buf), "AsyncFile%d", numAsyncFiles);
@@ -76,27 +75,25 @@ AsyncFile::doStart()
theStartConditionPtr = NdbCondition_Create();
NdbMutex_Lock(theStartMutexPtr);
theStartFlag = false;
- container.conf = globalEmulatorData.theConfiguration;
- container.type = NdbfsThread;
- theThreadPtr = NdbThread_CreateWithFunc(runAsyncFile,
+
+ theThreadPtr = NdbThread_Create(runAsyncFile,
(void**)this,
stackSize,
(char*)&buf,
- NDB_THREAD_PRIO_MEAN,
- ndb_thread_add_thread_id,
- &container,
- sizeof(container),
- ndb_thread_remove_thread_id,
- &container,
- sizeof(container));
- if (theThreadPtr == 0)
- ERROR_SET(fatal, NDBD_EXIT_MEMALLOC, "","Could not allocate file system thread");
+ NDB_THREAD_PRIO_MEAN);
+ if (theThreadPtr == 0)
+ {
+ ERROR_SET(fatal, NDBD_EXIT_MEMALLOC,
+ "","Could not allocate file system thread");
+ }
NdbCondition_Wait(theStartConditionPtr,
theStartMutexPtr);
NdbMutex_Unlock(theStartMutexPtr);
NdbMutex_Destroy(theStartMutexPtr);
NdbCondition_Destroy(theStartConditionPtr);
+
+ return theThreadPtr;
}
void AsyncFile::shutdown()
=== modified file 'storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp'
--- a/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp 2008-08-28 08:11:47 +0000
+++ b/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp 2008-11-06 10:17:49 +0000
@@ -165,7 +165,7 @@ public:
void execute( Request* request );
- virtual void doStart();
+ virtual struct NdbThread* doStart();
virtual void shutdown();
=== modified file 'storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp'
--- a/storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp 2008-08-21 14:31:29 +0000
+++ b/storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp 2008-11-06 10:17:49 +0000
@@ -678,7 +678,8 @@ Ndbfs::createAsyncFile(){
AsyncFile* file = new PosixAsyncFile(* this);
#endif
- file->doStart();
+ struct NdbThread* thr = file->doStart();
+ globalEmulatorData.theConfiguration->addThread(thr, NdbfsThread);
// Put the file in list of all files
theFiles.push_back(file);
=== modified file 'storage/ndb/src/kernel/main.cpp'
--- a/storage/ndb/src/kernel/main.cpp 2008-10-29 17:02:11 +0000
+++ b/storage/ndb/src/kernel/main.cpp 2008-11-06 10:17:49 +0000
@@ -557,7 +557,7 @@ int main(int argc, char** argv)
theConfig->setupConfiguration();
systemInfo(* theConfig, * theConfig->m_logLevel);
- globalEmulatorData.theWatchDog->doStart();
+ NdbThread* pWatchdog = globalEmulatorData.theWatchDog->doStart();
{
/*
@@ -643,15 +643,24 @@ int main(int argc, char** argv)
"Connection to mgmd terminated before setup was complete",
"StopOnError missing");
- if (!globalTransporterRegistry.start_clients()){
+ NdbThread* pTrp = globalTransporterRegistry.start_clients();
+ if (pTrp == 0)
+ {
ndbout_c("globalTransporterRegistry.start_clients() failed");
exit(-1);
}
- globalEmulatorData.m_socket_server->startServer();
+
+ NdbThread* pSockServ = globalEmulatorData.m_socket_server->startServer();
+
+ globalEmulatorData.theConfiguration->addThread(pTrp, SocketClientThread);
+ globalEmulatorData.theConfiguration->addThread(pWatchdog, WatchDogThread);
+ globalEmulatorData.theConfiguration->addThread(pSockServ, SocketServerThread);
// theConfig->closeConfiguration();
{
- Uint32 inx = globalEmulatorData.theConfiguration->addThreadId(MainThread);
+ NdbThread *pThis = NdbThread_CreateObject(0);
+ Uint32 inx = globalEmulatorData.theConfiguration->addThread(pThis,
+ MainThread);
globalEmulatorData.theThreadConfig->ipControlLoop(inx);
globalEmulatorData.theConfiguration->removeThreadId(inx);
}
=== modified file 'storage/ndb/src/kernel/vm/Configuration.cpp'
--- a/storage/ndb/src/kernel/vm/Configuration.cpp 2008-11-06 10:13:37 +0000
+++ b/storage/ndb/src/kernel/vm/Configuration.cpp 2008-11-06 10:17:49 +0000
@@ -1022,7 +1022,7 @@ Configuration::setAllRealtimeScheduler()
{
if (threadInfo[i].type != NotInUse)
{
- if (setRealtimeScheduler(threadInfo[i].threadHandle,
+ if (setRealtimeScheduler(threadInfo[i].pThread,
threadInfo[i].type,
_realtimeScheduler,
FALSE))
@@ -1039,7 +1039,7 @@ Configuration::setAllLockCPU(bool exec_t
{
if (threadInfo[i].type != NotInUse)
{
- if (setLockCPU(threadInfo[i].threadId,
+ if (setLockCPU(threadInfo[i].pThread,
threadInfo[i].type,
exec_thread,
FALSE))
@@ -1049,7 +1049,7 @@ Configuration::setAllLockCPU(bool exec_t
}
int
-Configuration::setRealtimeScheduler(NDB_THAND_TYPE threadHandle,
+Configuration::setRealtimeScheduler(NdbThread* pThread,
enum ThreadTypes type,
bool real_time,
bool init)
@@ -1058,12 +1058,10 @@ Configuration::setRealtimeScheduler(NDB_
We ignore thread characteristics on platforms where we cannot
determine the thread id.
*/
- if (!threadHandle)
- return 0;
if (!init || real_time)
{
int error_no;
- if ((error_no = NdbThread_SetScheduler(threadHandle, real_time,
+ if ((error_no = NdbThread_SetScheduler(pThread, real_time,
(type != MainThread))))
{
//Warning, no permission to set scheduler
@@ -1074,20 +1072,21 @@ Configuration::setRealtimeScheduler(NDB_
}
int
-Configuration::setLockCPU(NDB_TID_TYPE threadId,
+Configuration::setLockCPU(NdbThread * pThread,
enum ThreadTypes type,
bool exec_thread,
bool init)
{
Uint32 cpu_id;
+ int tid = NdbThread_GetTid(pThread);
+ if (tid == -1)
+ return 0;
/*
We ignore thread characteristics on platforms where we cannot
determine the thread id.
We only set new lock CPU characteristics for the threads for which
it has changed
*/
- if (!threadId)
- return 0;
if ((exec_thread && type != MainThread) ||
(!exec_thread && type == MainThread))
return 0;
@@ -1099,9 +1098,9 @@ Configuration::setLockCPU(NDB_TID_TYPE t
cpu_id != NO_LOCK_CPU)
{
int error_no;
- ndbout << "Lock threadId = " << (unsigned)threadId;
+ ndbout << "Lock threadId = " << tid;
ndbout << " to CPU id = " << cpu_id << endl;
- if ((error_no = NdbThread_LockCPU(threadId, cpu_id)))
+ if ((error_no = NdbThread_LockCPU(pThread, cpu_id)))
{
ndbout << "Failed to lock CPU, error_no = " << error_no << endl;
;//Warning, no permission to lock thread to CPU
@@ -1111,42 +1110,9 @@ Configuration::setLockCPU(NDB_TID_TYPE t
return 0;
}
-void ndb_thread_fill_thread_object(void *param, uint *len, my_bool server)
-{
- struct ThreadContainer container;
-
- memset((char*)&container, sizeof(container), 0);
- container.conf = globalEmulatorData.theConfiguration;
- container.type = server ? SocketServerThread : SocketClientThread;
- memcpy((char*)param, (char*)&container, sizeof(container));
- *len = sizeof(container);
-}
-
-void*
-ndb_thread_add_thread_id(void *param)
-{
- struct ThreadContainer container;
-
- memcpy((char*)&container, param, sizeof(struct ThreadContainer));
- container.index = container.conf->addThreadId(container.type);
- memcpy(param, (char*)&container, sizeof(struct ThreadContainer));
- return NULL;
-}
-
-void*
-ndb_thread_remove_thread_id(void *param)
-{
- struct ThreadContainer container;
-
- memcpy((char*)&container, param, sizeof(struct ThreadContainer));
- container.conf->removeThreadId(container.index);
- return NULL;
-}
-
-Uint32 Configuration::addThreadId(enum ThreadTypes type)
+Uint32
+Configuration::addThread(struct NdbThread* pThread, enum ThreadTypes type)
{
- NDB_TID_TYPE threadId;
- NDB_THAND_TYPE threadHandle;
Uint32 i;
NdbMutex_Lock(threadIdMutex);
for (i = 0; i < threadInfo.size(); i++)
@@ -1159,14 +1125,11 @@ Uint32 Configuration::addThreadId(enum T
struct ThreadInfo tmp;
threadInfo.push_back(tmp);
}
- threadHandle = NdbThread_getThreadHandle();
- threadInfo[i].threadHandle = threadHandle;
- threadId = NdbThread_getThreadId();
- threadInfo[i].threadId = threadId;
+ threadInfo[i].pThread = pThread;
threadInfo[i].type = type;
NdbMutex_Unlock(threadIdMutex);
- setRealtimeScheduler(threadHandle, type, _realtimeScheduler, TRUE);
- setLockCPU(threadId, type, (type == MainThread), TRUE);
+ setRealtimeScheduler(pThread, type, _realtimeScheduler, TRUE);
+ setLockCPU(pThread, type, (type == MainThread), TRUE);
return i;
}
@@ -1174,8 +1137,7 @@ void
Configuration::removeThreadId(Uint32 index)
{
NdbMutex_Lock(threadIdMutex);
- threadInfo[index].threadId = 0;
- threadInfo[index].threadHandle = 0;
+ threadInfo[index].pThread = 0;
threadInfo[index].type = NotInUse;
NdbMutex_Unlock(threadIdMutex);
}
@@ -1186,12 +1148,12 @@ Configuration::yield_main(Uint32 index,
if (_realtimeScheduler)
{
if (start)
- setRealtimeScheduler(threadInfo[index].threadHandle,
+ setRealtimeScheduler(threadInfo[index].pThread,
threadInfo[index].type,
FALSE,
FALSE);
else
- setRealtimeScheduler(threadInfo[index].threadHandle,
+ setRealtimeScheduler(threadInfo[index].pThread,
threadInfo[index].type,
TRUE,
FALSE);
@@ -1204,8 +1166,7 @@ Configuration::initThreadArray()
NdbMutex_Lock(threadIdMutex);
for (Uint32 i = 0; i < threadInfo.size(); i++)
{
- threadInfo[i].threadId = 0;
- threadInfo[i].threadHandle = 0;
+ threadInfo[i].pThread = 0;
threadInfo[i].type = NotInUse;
}
NdbMutex_Unlock(threadIdMutex);
=== modified file 'storage/ndb/src/kernel/vm/Configuration.hpp'
--- a/storage/ndb/src/kernel/vm/Configuration.hpp 2008-09-12 12:55:29 +0000
+++ b/storage/ndb/src/kernel/vm/Configuration.hpp 2008-11-06 10:17:49 +0000
@@ -37,20 +37,12 @@ enum ThreadTypes
struct ThreadInfo
{
- NDB_TID_TYPE threadId;
- NDB_THAND_TYPE threadHandle;
enum ThreadTypes type;
+ struct NdbThread* pThread;
};
class Configuration;
-struct ThreadContainer
-{
- Configuration *conf;
- enum ThreadTypes type;
- Uint32 index;
-};
-
class ConfigRetriever;
class Configuration {
@@ -86,15 +78,15 @@ public:
void setAllRealtimeScheduler();
void setAllLockCPU(bool exec_thread);
- int setLockCPU(NDB_TID_TYPE threadId,
+ int setLockCPU(NdbThread*,
enum ThreadTypes type,
bool exec_thread,
bool init);
- int setRealtimeScheduler(NDB_THAND_TYPE threadHandle,
+ int setRealtimeScheduler(NdbThread*,
enum ThreadTypes type,
bool real_time,
bool init);
- Uint32 addThreadId(enum ThreadTypes type);
+ Uint32 addThread(struct NdbThread*, enum ThreadTypes type);
void removeThreadId(Uint32 index);
void yield_main(Uint32 thread_index, bool start);
void initThreadArray();
=== modified file 'storage/ndb/src/kernel/vm/DynArr256.cpp'
--- a/storage/ndb/src/kernel/vm/DynArr256.cpp 2007-08-23 13:31:26 +0000
+++ b/storage/ndb/src/kernel/vm/DynArr256.cpp 2008-11-03 08:38:27 +0000
@@ -323,7 +323,7 @@ DynArr256::expand(Uint32 pos)
alloc[idx] = m_head.m_ptr_i;
m_head.m_sz = 1;
- for (Uint32 i = 0; i<idx; i++)
+ for (i = 0; i<idx; i++)
{
m_head.m_ptr_i = alloc[i];
Uint32 * ptr = get(0);
=== modified file 'storage/ndb/src/kernel/vm/WatchDog.cpp'
--- a/storage/ndb/src/kernel/vm/WatchDog.cpp 2008-08-21 06:36:31 +0000
+++ b/storage/ndb/src/kernel/vm/WatchDog.cpp 2008-11-06 10:17:49 +0000
@@ -101,24 +101,17 @@ WatchDog::unregisterWatchedThread(Uint32
NdbMutex_Unlock(m_mutex);
}
-void
+struct NdbThread*
WatchDog::doStart()
{
- struct ThreadContainer container;
theStop = false;
- container.conf = globalEmulatorData.theConfiguration;
- container.type = WatchDogThread;
- theThreadPtr = NdbThread_CreateWithFunc(runWatchDog,
+ theThreadPtr = NdbThread_Create(runWatchDog,
(void**)this,
32768,
"ndb_watchdog",
- NDB_THREAD_PRIO_HIGH,
- ndb_thread_add_thread_id,
- &container,
- sizeof(container),
- ndb_thread_remove_thread_id,
- &container,
- sizeof(container));
+ NDB_THREAD_PRIO_HIGH);
+
+ return theThreadPtr;
}
void
=== modified file 'storage/ndb/src/kernel/vm/WatchDog.hpp'
--- a/storage/ndb/src/kernel/vm/WatchDog.hpp 2008-01-01 12:45:11 +0000
+++ b/storage/ndb/src/kernel/vm/WatchDog.hpp 2008-11-06 10:17:49 +0000
@@ -47,7 +47,7 @@ public:
WatchDog(Uint32 interval = 3000);
~WatchDog();
- void doStart();
+ struct NdbThread* doStart();
void doStop();
Uint32 setCheckInterval(Uint32 interval);
=== modified file 'storage/ndb/src/ndbapi/TransporterFacade.cpp'
--- a/storage/ndb/src/ndbapi/TransporterFacade.cpp 2008-11-04 08:43:06 +0000
+++ b/storage/ndb/src/ndbapi/TransporterFacade.cpp 2008-11-06 13:52:28 +0000
@@ -58,22 +58,6 @@ static int indexToNumber(int index)
/*****************************************************************************
* Call back functions
*****************************************************************************/
-
-void* ndb_thread_add_thread_id(void *param)
-{
- return NULL;
-}
-
-void *ndb_thread_remove_thread_id(void *param)
-{
- return NULL;
-}
-
-void ndb_thread_fill_thread_object(void *param, uint *len, my_bool server)
-{
- *len = 0;
-}
-
void
TransporterFacade::reportError(NodeId nodeId,
TransporterError errorCode, const char *info)
@@ -506,7 +490,7 @@ runSendRequest_C(void * me)
void TransporterFacade::threadMainSend(void)
{
theTransporterRegistry->startSending();
- if (!theTransporterRegistry->start_clients()){
+ if (theTransporterRegistry->start_clients() == 0){
ndbout_c("Unable to start theTransporterRegistry->start_clients");
exit(0);
}
=== modified file 'storage/ndb/test/ndbapi/testMgm.cpp'
--- a/storage/ndb/test/ndbapi/testMgm.cpp 2008-10-06 09:49:27 +0000
+++ b/storage/ndb/test/ndbapi/testMgm.cpp 2008-11-03 08:38:27 +0000
@@ -701,7 +701,7 @@ int getMgmLogInfo(NdbMgmHandle h, off_t
NdbMgmd mgmd;
const char *mgm= mgmd.getConnectString();
- int i, r, ncol;
+ int r, ncol;
char rowbuf[1024];
char **cols;
int current_size_colnum= 0;
@@ -718,7 +718,7 @@ int getMgmLogInfo(NdbMgmHandle h, off_t
ndb_mgm_ndbinfo_getcolums(h,ncol,100,cols);
- for(i=0;i<ncol;i++)
+ for(int i=0;i<ncol;i++)
{
if(strcmp(cols[i],"CURRENT_SIZE")==0)
current_size_colnum= i;
=== modified file 'storage/ndb/test/ndbapi/testNodeRestart.cpp'
--- a/storage/ndb/test/ndbapi/testNodeRestart.cpp 2008-10-28 11:00:17 +0000
+++ b/storage/ndb/test/ndbapi/testNodeRestart.cpp 2008-11-03 08:38:27 +0000
@@ -1469,7 +1469,6 @@ runBug26481(NDBT_Context* ctx, NDBT_Step
int
runBug26450(NDBT_Context* ctx, NDBT_Step* step)
{
- Uint32 i;
NdbRestarter res;
Ndb* pNdb = GETNDB(step);
@@ -1497,7 +1496,7 @@ runBug26450(NDBT_Context* ctx, NDBT_Step
if (runClearTable(ctx, step))
return NDBT_FAILED;
- for (i = 0; i < 2; i++)
+ for (int i = 0; i < 2; i++)
{
if (res.restartAll(false, true, i > 0))
return NDBT_FAILED;
=== modified file 'storage/ndb/test/ndbapi/testScanFilter.cpp'
--- a/storage/ndb/test/ndbapi/testScanFilter.cpp 2008-10-07 06:00:54 +0000
+++ b/storage/ndb/test/ndbapi/testScanFilter.cpp 2008-11-03 08:38:27 +0000
@@ -709,13 +709,14 @@ void ndbapi_tuples(Ndb *ndb, char *str,
ERR_EXIT(dict, "Can't get table"TABLE_NAME);
const NdbDictionary::Column *col[COL_LEN];
- for(int i = 0; i < COL_LEN; i++)
+
+ for(int ii = 0; ii < COL_LEN; ii++)
{
char tmp[128];
- col[i] = table->getColumn(COL_NAME[i]);
- if(!col[i])
+ col[ii] = table->getColumn(COL_NAME[ii]);
+ if(!col[ii])
{
- BaseString::snprintf(tmp, 128, "Can't get column %s", COL_NAME[i]);
+ BaseString::snprintf(tmp, 128, "Can't get column %s", COL_NAME[ii]);
ERR_EXIT(dict, tmp);
}
}
@@ -736,13 +737,13 @@ void ndbapi_tuples(Ndb *ndb, char *str,
ERR_EXIT(scan, "Can't set up read");
NdbRecAttr *rec[COL_LEN];
- for(int i = 0; i < COL_LEN; i++)
+ for(int ii = 0; ii < COL_LEN; ii++)
{
char tmp[128];
- rec[i] = scan->getValue(COL_NAME[i]);
- if(!rec[i])
+ rec[ii] = scan->getValue(COL_NAME[ii]);
+ if(!rec[ii])
{
- BaseString::snprintf(tmp, 128, "Can't get rec of %s", COL_NAME[i]);
+ BaseString::snprintf(tmp, 128, "Can't get rec of %s", COL_NAME[ii]);
ERR_EXIT(scan, tmp);
}
}
=== modified file 'storage/ndb/test/ndbapi/test_event_merge.cpp'
--- a/storage/ndb/test/ndbapi/test_event_merge.cpp 2008-10-07 06:20:59 +0000
+++ b/storage/ndb/test/ndbapi/test_event_merge.cpp 2008-11-03 08:38:27 +0000
@@ -1684,6 +1684,7 @@ runops()
Op* gci_op[g_maxtab][g_maxpk];
uint left = 0; // number of table pks with ops
Uint32 pk1;
+ unsigned int i;
for (unsigned int i = 0; i < maxrun(); i++) {
Run& r = run(i);
for (pk1 = 0; pk1 < g_opts.maxpk; pk1++) {
@@ -1702,9 +1703,9 @@ runops()
left++;
}
}
- uint i;
+
while (left != 0) {
- i = urandom(maxrun());
+ unsigned int i = urandom(maxrun());
pk1 = urandom(g_opts.maxpk);
if (gci_op[i][pk1] == 0)
continue;
| Thread |
|---|
| • bzr commit into mysql-5.1 branch (msvensson:3046) | Magnus Svensson | 6 Nov |