summaryrefslogtreecommitdiff
path: root/ndb/src
diff options
context:
space:
mode:
authorunknown <tulin@mysql.com>2005-02-01 19:01:37 +0100
committerunknown <tulin@mysql.com>2005-02-01 19:01:37 +0100
commitcf660b001ef6ba154b1d8d15b534a253dcfc14e0 (patch)
tree7e9b65ed010e4892f4b52ca72eb4f85ef5fd3347 /ndb/src
parent514b2364b4156e23fb15f4506a50877011b9c7ef (diff)
downloadmariadb-git-cf660b001ef6ba154b1d8d15b534a253dcfc14e0.tar.gz
cleanup and streamlining of thread create/exit in ndb
Diffstat (limited to 'ndb/src')
-rw-r--r--ndb/src/common/portlib/NdbPortLibTest.cpp16
-rw-r--r--ndb/src/common/portlib/NdbThread.c40
-rw-r--r--ndb/src/common/transporter/TransporterRegistry.cpp5
-rw-r--r--ndb/src/common/util/SocketServer.cpp9
-rw-r--r--ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp3
-rw-r--r--ndb/src/kernel/blocks/ndbfs/MemoryChannelTest/MemoryChannelTest.cpp4
-rw-r--r--ndb/src/kernel/vm/WatchDog.cpp3
-rw-r--r--ndb/src/mgmclient/CommandInterpreter.cpp6
-rw-r--r--ndb/src/mgmsrv/MgmtSrvr.cpp10
-rw-r--r--ndb/src/ndbapi/ClusterMgr.cpp4
-rw-r--r--ndb/src/ndbapi/TransporterFacade.cpp10
-rw-r--r--ndb/src/ndbapi/ndb_cluster_connection.cpp3
12 files changed, 32 insertions, 81 deletions
diff --git a/ndb/src/common/portlib/NdbPortLibTest.cpp b/ndb/src/common/portlib/NdbPortLibTest.cpp
index 55b9ccec5f2..d7892411851 100644
--- a/ndb/src/common/portlib/NdbPortLibTest.cpp
+++ b/ndb/src/common/portlib/NdbPortLibTest.cpp
@@ -54,10 +54,7 @@ extern "C" void* thread1func(void* arg)
if (arg1 != 7)
fail("TEST1", "Wrong arg");
- NdbThread_Exit(returnvalue);
-
- return NULL;
-
+ return returnvalue;
}
// test 2 variables and funcs
@@ -80,10 +77,7 @@ extern "C" void* test2func(void* arg)
fail("TEST2", "Failed to unlock mutex");
int returnvalue = arg1;
- NdbThread_Exit(returnvalue);
-
- return NULL;
-
+ return returnvalue;
}
@@ -129,8 +123,7 @@ extern "C" void* testfunc(void* arg)
}
while(tmpVar<100);
- NdbThread_Exit(0);
- return NULL;
+ return 0;
}
extern "C" void* testTryLockfunc(void* arg)
@@ -169,8 +162,7 @@ extern "C" void* testTryLockfunc(void* arg)
}
while(tmpVar<100);
- NdbThread_Exit(0);
- return NULL;
+ return 0;
}
diff --git a/ndb/src/common/portlib/NdbThread.c b/ndb/src/common/portlib/NdbThread.c
index 5f2e6021c43..c1137efdb41 100644
--- a/ndb/src/common/portlib/NdbThread.c
+++ b/ndb/src/common/portlib/NdbThread.c
@@ -17,7 +17,7 @@
#include <ndb_global.h>
#include <NdbThread.h>
-#include <pthread.h>
+#include <my_pthread.h>
#include <NdbMem.h>
#define MAX_THREAD_NAME 16
@@ -39,21 +39,29 @@ struct NdbThread
static
void*
ndb_thread_wrapper(void* _ss){
- void * ret;
- struct NdbThread * ss = (struct NdbThread *)_ss;
- DBUG_ENTER("ndb_thread_wrapper");
-#ifdef NDB_SHM_TRANSPORTER
- if (g_ndb_shm_signum)
+ my_thread_init();
{
- sigset_t mask;
- DBUG_PRINT("info",("Block signum %d",g_ndb_shm_signum));
- sigemptyset(&mask);
- sigaddset(&mask, g_ndb_shm_signum);
- pthread_sigmask(SIG_BLOCK, &mask, 0);
- }
+ DBUG_ENTER("ndb_thread_wrapper");
+#ifdef NDB_SHM_TRANSPORTER
+ if (g_ndb_shm_signum)
+ {
+ sigset_t mask;
+ DBUG_PRINT("info",("Block signum %d",g_ndb_shm_signum));
+ sigemptyset(&mask);
+ sigaddset(&mask, g_ndb_shm_signum);
+ pthread_sigmask(SIG_BLOCK, &mask, 0);
+ }
#endif
- ret= (* ss->func)(ss->object);
- DBUG_RETURN(ret);
+ {
+ void *ret;
+ struct NdbThread * ss = (struct NdbThread *)_ss;
+ ret= (* ss->func)(ss->object);
+ my_thread_end();
+ NdbThread_Exit(ret);
+ }
+ /* will never be reached */
+ DBUG_RETURN(0);
+ }
}
@@ -130,9 +138,9 @@ int NdbThread_WaitFor(struct NdbThread* p_wait_thread, void** status)
}
-void NdbThread_Exit(int status)
+void NdbThread_Exit(void *status)
{
- pthread_exit(&status);
+ pthread_exit(status);
}
diff --git a/ndb/src/common/transporter/TransporterRegistry.cpp b/ndb/src/common/transporter/TransporterRegistry.cpp
index 462cde76740..439730435ec 100644
--- a/ndb/src/common/transporter/TransporterRegistry.cpp
+++ b/ndb/src/common/transporter/TransporterRegistry.cpp
@@ -1104,11 +1104,8 @@ TransporterRegistry::setIOState(NodeId nodeId, IOState state) {
static void *
run_start_clients_C(void * me)
{
- my_thread_init();
((TransporterRegistry*) me)->start_clients_thread();
- my_thread_end();
- NdbThread_Exit(0);
- return me;
+ return 0;
}
// Run by kernel thread
diff --git a/ndb/src/common/util/SocketServer.cpp b/ndb/src/common/util/SocketServer.cpp
index 8bee256684d..da06389b5df 100644
--- a/ndb/src/common/util/SocketServer.cpp
+++ b/ndb/src/common/util/SocketServer.cpp
@@ -186,11 +186,7 @@ extern "C"
void*
socketServerThread_C(void* _ss){
SocketServer * ss = (SocketServer *)_ss;
-
- my_thread_init();
ss->doRun();
- my_thread_end();
- NdbThread_Exit(0);
return 0;
}
@@ -309,11 +305,8 @@ void*
sessionThread_C(void* _sc){
SocketServer::Session * si = (SocketServer::Session *)_sc;
- my_thread_init();
if(!transfer(si->m_socket)){
si->m_stopped = true;
- my_thread_end();
- NdbThread_Exit(0);
return 0;
}
@@ -325,8 +318,6 @@ sessionThread_C(void* _sc){
}
si->m_stopped = true;
- my_thread_end();
- NdbThread_Exit(0);
return 0;
}
diff --git a/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp b/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp
index ad6c0fd5283..f76440a462a 100644
--- a/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp
+++ b/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp
@@ -82,7 +82,6 @@ static int numAsyncFiles = 0;
extern "C" void * runAsyncFile(void* arg)
{
- my_thread_init();
((AsyncFile*)arg)->run();
return (NULL);
}
@@ -876,8 +875,6 @@ void AsyncFile::endReq()
{
// Thread is ended with return
if (theWriteBuffer) NdbMem_Free(theWriteBuffer);
- my_thread_end();
- NdbThread_Exit(0);
}
diff --git a/ndb/src/kernel/blocks/ndbfs/MemoryChannelTest/MemoryChannelTest.cpp b/ndb/src/kernel/blocks/ndbfs/MemoryChannelTest/MemoryChannelTest.cpp
index aeab9f7828d..b98c60693f4 100644
--- a/ndb/src/kernel/blocks/ndbfs/MemoryChannelTest/MemoryChannelTest.cpp
+++ b/ndb/src/kernel/blocks/ndbfs/MemoryChannelTest/MemoryChannelTest.cpp
@@ -40,7 +40,6 @@ extern "C" void* runProducer(void*arg)
NdbSleep_MilliSleep(i);
i++;
}
- NdbThread_Exit(0);
return NULL;
}
@@ -58,7 +57,6 @@ extern "C" void* runConsumer(void* arg)
delete p;
}
- NdbThread_Exit(0);
return NULL;
}
@@ -92,7 +90,6 @@ extern "C" void* runProducer2(void*arg)
NdbSleep_MilliSleep(i);
i++;
}
- NdbThread_Exit(0);
return NULL;
}
@@ -111,7 +108,6 @@ extern "C" void* runConsumer2(void* arg)
delete p;
}
ndbout << "Consumer2: " << count << " received" << endl;
- NdbThread_Exit(0);
return NULL;
}
diff --git a/ndb/src/kernel/vm/WatchDog.cpp b/ndb/src/kernel/vm/WatchDog.cpp
index 4e07dc1df90..23475a478d3 100644
--- a/ndb/src/kernel/vm/WatchDog.cpp
+++ b/ndb/src/kernel/vm/WatchDog.cpp
@@ -27,10 +27,7 @@
extern "C"
void*
runWatchDog(void* w){
- my_thread_init();
((WatchDog*)w)->run();
- my_thread_end();
- NdbThread_Exit(0);
return NULL;
}
diff --git a/ndb/src/mgmclient/CommandInterpreter.cpp b/ndb/src/mgmclient/CommandInterpreter.cpp
index cbf7776fe06..025bed2bc09 100644
--- a/ndb/src/mgmclient/CommandInterpreter.cpp
+++ b/ndb/src/mgmclient/CommandInterpreter.cpp
@@ -457,8 +457,6 @@ event_thread_run(void* m)
{
NdbMgmHandle handle= *(NdbMgmHandle*)m;
- my_thread_init();
-
int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_BACKUP, 0 };
int fd = ndb_mgm_listen_event(handle, filter);
if (fd > 0)
@@ -478,9 +476,7 @@ event_thread_run(void* m)
do_event_thread= -1;
}
- my_thread_end();
- NdbThread_Exit(0);
- return 0;
+ return NULL;
}
bool
diff --git a/ndb/src/mgmsrv/MgmtSrvr.cpp b/ndb/src/mgmsrv/MgmtSrvr.cpp
index f698099141a..66c9a6448aa 100644
--- a/ndb/src/mgmsrv/MgmtSrvr.cpp
+++ b/ndb/src/mgmsrv/MgmtSrvr.cpp
@@ -70,12 +70,7 @@ void *
MgmtSrvr::logLevelThread_C(void* m)
{
MgmtSrvr *mgm = (MgmtSrvr*)m;
- my_thread_init();
mgm->logLevelThreadRun();
-
- my_thread_end();
- NdbThread_Exit(0);
- /* NOTREACHED */
return 0;
}
@@ -83,12 +78,7 @@ void *
MgmtSrvr::signalRecvThread_C(void *m)
{
MgmtSrvr *mgm = (MgmtSrvr*)m;
- my_thread_init();
mgm->signalRecvThreadRun();
-
- my_thread_end();
- NdbThread_Exit(0);
- /* NOTREACHED */
return 0;
}
diff --git a/ndb/src/ndbapi/ClusterMgr.cpp b/ndb/src/ndbapi/ClusterMgr.cpp
index e10b2e1d82c..1fe0cedbd6c 100644
--- a/ndb/src/ndbapi/ClusterMgr.cpp
+++ b/ndb/src/ndbapi/ClusterMgr.cpp
@@ -54,7 +54,6 @@ runClusterMgr_C(void * me)
#ifdef NDB_OSE
NdbSleep_MilliSleep(50);
#endif
- NdbThread_Exit(0);
return NULL;
}
@@ -560,10 +559,7 @@ extern "C"
void*
runArbitMgr_C(void* me)
{
- my_thread_init();
((ArbitMgr*) me)->threadMain();
- my_thread_end();
- NdbThread_Exit(0);
return NULL;
}
diff --git a/ndb/src/ndbapi/TransporterFacade.cpp b/ndb/src/ndbapi/TransporterFacade.cpp
index 031ee6315e8..5582143be44 100644
--- a/ndb/src/ndbapi/TransporterFacade.cpp
+++ b/ndb/src/ndbapi/TransporterFacade.cpp
@@ -405,11 +405,8 @@ extern "C"
void*
runSendRequest_C(void * me)
{
- my_thread_init();
((TransporterFacade*) me)->threadMainSend();
- my_thread_end();
- NdbThread_Exit(0);
- return me;
+ return 0;
}
void TransporterFacade::threadMainSend(void)
@@ -443,11 +440,8 @@ extern "C"
void*
runReceiveResponse_C(void * me)
{
- my_thread_init();
((TransporterFacade*) me)->threadMainReceive();
- my_thread_end();
- NdbThread_Exit(0);
- return me;
+ return 0;
}
void TransporterFacade::threadMainReceive(void)
diff --git a/ndb/src/ndbapi/ndb_cluster_connection.cpp b/ndb/src/ndbapi/ndb_cluster_connection.cpp
index 5df707e211d..ab32d6abb8e 100644
--- a/ndb/src/ndbapi/ndb_cluster_connection.cpp
+++ b/ndb/src/ndbapi/ndb_cluster_connection.cpp
@@ -87,11 +87,8 @@ const char *Ndb_cluster_connection::get_connectstring(char *buf,
extern "C" pthread_handler_decl(run_ndb_cluster_connection_connect_thread, me)
{
- my_thread_init();
g_run_connect_thread= 1;
((Ndb_cluster_connection_impl*) me)->connect_thread();
- my_thread_end();
- NdbThread_Exit(0);
return me;
}