Commit cf660b00 authored by unknown's avatar unknown
Browse files

cleanup and streamlining of thread create/exit in ndb

parent 514b2364
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ int NdbThread_WaitFor(struct NdbThread* p_wait_thread, void** status);
 *   
 * *  status: exit code
 */
void NdbThread_Exit(int status);
void NdbThread_Exit(void *status);

/**
 * Set thread concurrency level
+4 −12
Original line number Diff line number Diff line
@@ -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;
}


+24 −16
Original line number Diff line number Diff line
@@ -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,8 +39,8 @@ struct NdbThread
static
void*
ndb_thread_wrapper(void* _ss){
  void * ret;
  struct NdbThread * ss = (struct NdbThread *)_ss;
  my_thread_init();
  {
    DBUG_ENTER("ndb_thread_wrapper");
#ifdef NDB_SHM_TRANSPORTER
    if (g_ndb_shm_signum)
@@ -52,8 +52,16 @@ ndb_thread_wrapper(void* _ss){
      pthread_sigmask(SIG_BLOCK, &mask, 0);
    }
#endif
    {
      void *ret;
      struct NdbThread * ss = (struct NdbThread *)_ss;
      ret= (* ss->func)(ss->object);
  DBUG_RETURN(ret);
      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);
}


+1 −4
Original line number Diff line number Diff line
@@ -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
+0 −9
Original line number Diff line number Diff line
@@ -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;
}

Loading