Пример #1
0
void
ClusterMgr::doStop( ){
  DBUG_ENTER("ClusterMgr::doStop");
  {
    /* Ensure stop is only executed once */
    Guard g(clusterMgrThreadMutex);
    if(theStop == 1){
      DBUG_VOID_RETURN;
    }
    theStop = 1;
  }

  void *status;
  if (theClusterMgrThread) {
    NdbThread_WaitFor(theClusterMgrThread, &status);  
    NdbThread_Destroy(&theClusterMgrThread);
  }

  if (theArbitMgr != NULL)
  {
    theArbitMgr->doStop(NULL);
  }
  {
    /* Need protection for poll calls in close */
    Guard g(clusterMgrThreadMutex);
    this->close(); // disconnect from TransporterFacade
  }

  DBUG_VOID_RETURN;
}
Пример #2
0
void
ClusterMgr::doStop( ) {
    DBUG_ENTER("ClusterMgr::doStop");
    {
        /* Ensure stop is only executed once */
        Guard g(clusterMgrThreadMutex);
        if(theStop == 1) {
            DBUG_VOID_RETURN;
        }
        theStop = 1;
    }

    void *status;
    if (theClusterMgrThread) {
        NdbThread_WaitFor(theClusterMgrThread, &status);
        NdbThread_Destroy(&theClusterMgrThread);
    }

    if (theArbitMgr != NULL)
    {
        theArbitMgr->doStop(NULL);
    }
    {
        /**
         * Need protection against concurrent execution of do_poll in main
         * thread. We cannot rely only on the trp_client lock since it is
         * not supposed to be locked when calling close (it is locked as
         * part of the close logic.
         */
        Guard g(clusterMgrThreadMutex);
        this->close(); // disconnect from TransporterFacade
    }

    DBUG_VOID_RETURN;
}
Пример #3
0
void NDBT_TestCaseImpl1::waitSteps(){
  NdbMutex_Lock(waitThreadsMutexPtr);
  while(numStepsCompleted != steps.size())
    NdbCondition_Wait(waitThreadsCondPtr,
		     waitThreadsMutexPtr);

  unsigned completedSteps = 0;  
  unsigned i;
  for(i=0; i<steps.size(); i++){
    if (results[i] != NORESULT){
      completedSteps++;
      if (results[i] == NDBT_OK)
	numStepsOk++;
      else
	numStepsFail++;
    }       
  }
  require(completedSteps == steps.size());
  require(completedSteps == numStepsCompleted);
  
  NdbMutex_Unlock(waitThreadsMutexPtr);
  void *status;
  for(i=0; i<steps.size();i++){
    NdbThread_WaitFor(threads[i], &status);
    NdbThread_Destroy(&threads[i]);   
  }
  threads.clear();
}
Пример #4
0
void
WatchDog::doStop(){
  void *status;
  theStop = true;
  if(theThreadPtr){
    NdbThread_WaitFor(theThreadPtr, &status);
    NdbThread_Destroy(&theThreadPtr);
  }
}
Пример #5
0
void
AsyncIoThread::shutdown()
{
  void *status;
  Request request;
  request.action = Request::end;
  this->theMemoryChannelPtr->writeChannel( &request );
  NdbThread_WaitFor(theThreadPtr, &status);
  NdbThread_Destroy(&theThreadPtr);
}
Пример #6
0
AsyncFile::~AsyncFile() 
{
  void *status;
  Request request;
  request.action = Request::end;
  theMemoryChannelPtr->writeChannel( &request );
  NdbThread_WaitFor(theThreadPtr, &status);
  NdbThread_Destroy(&theThreadPtr);
  delete theMemoryChannelPtr;
}
Пример #7
0
bool
TransporterRegistry::stop_clients()
{
  if (m_start_clients_thread) {
    m_run_start_clients_thread= false;
    void* status;
    NdbThread_WaitFor(m_start_clients_thread, &status);
    NdbThread_Destroy(&m_start_clients_thread);
  }
  return true;
}
void
SocketServer::stopServer(){
  m_threadLock.lock();
  if(m_thread != 0){
    m_stopThread = true;
    
    void * res;
    NdbThread_WaitFor(m_thread, &res);
    NdbThread_Destroy(&m_thread);
    m_thread = 0;
  }
  m_threadLock.unlock();
}
Пример #9
0
NDBT_Thread::~NDBT_Thread()
{
  if (m_thread != 0) {
    NdbThread_Destroy(&m_thread);
    m_thread = 0;
  }
  if (m_cond != 0) {
    NdbCondition_Destroy(m_cond);
    m_cond = 0;
  }
  if (m_mutex != 0) {
    NdbMutex_Destroy(m_mutex);
    m_mutex = 0;
  }
}
Пример #10
0
void
ClusterMgr::doStop( ){
  DBUG_ENTER("ClusterMgr::doStop");
  NdbMutex_Lock(clusterMgrThreadMutex);
  if(theStop){
    NdbMutex_Unlock(clusterMgrThreadMutex);
    DBUG_VOID_RETURN;
  }
  void *status;
  theStop = 1;
  if (theClusterMgrThread) {
    NdbThread_WaitFor(theClusterMgrThread, &status);  
    NdbThread_Destroy(&theClusterMgrThread);
  }
  NdbMutex_Unlock(clusterMgrThreadMutex);
  DBUG_VOID_RETURN;
}
Пример #11
0
void CNdbThreadWorker::DestroyThread()
{
	LOG_NDB_FUNCTION();

	assert(ETS_Closed == CNdbThreadState::GetState());

	if (nullptr == m_pThread)
		return;

	void* threadStatus = nullptr;
	if (0 != NDB_CALL_FUNCTION(NdbThread_WaitFor(m_pThread, &threadStatus)))
	{
		LogNdbCritical << "FAIL : NdbThread_WaitFor()" << endl;
		return;
	}

	NDB_CALL_FUNCTION(NdbThread_Destroy(&m_pThread));
}
Пример #12
0
void
SocketServer::checkSessionsImpl()
{
  for(int i = m_sessions.size() - 1; i >= 0; i--)
  {
    if(m_sessions[i].m_session->m_stopped)
    {
      if(m_sessions[i].m_thread != 0)
      {
	void* ret;
	NdbThread_WaitFor(m_sessions[i].m_thread, &ret);
	NdbThread_Destroy(&m_sessions[i].m_thread);
      } 
      m_sessions[i].m_session->stopSession();
      delete m_sessions[i].m_session;
      m_sessions.erase(i);
    }
  }
}
Пример #13
0
void
ndbd_alloc_touch_mem(void *p, size_t sz, volatile Uint32 * watchCounter)
{
  struct NdbThread *thread_ptr[TOUCH_PARALLELISM];
  struct AllocTouchMem touch_mem_struct[TOUCH_PARALLELISM];

  Uint32 tmp = 0;
  if (watchCounter == 0)
  {
    watchCounter = &tmp;
  }

  for (Uint32 i = 0; i < TOUCH_PARALLELISM; i++)
  {
    touch_mem_struct[i].watchCounter = watchCounter;
    touch_mem_struct[i].sz = sz;
    touch_mem_struct[i].p = p;
    touch_mem_struct[i].index = i;

    thread_ptr[i] = NULL;
    if (sz > MIN_START_THREAD_SIZE)
    {
      thread_ptr[i] = NdbThread_Create(touch_mem,
                                       (NDB_THREAD_ARG*)&touch_mem_struct[i],
                                       0,
                                       "touch_thread",
                                       NDB_THREAD_PRIO_MEAN);
    }
    if (thread_ptr[i] == NULL)
    {
      touch_mem((void*)&touch_mem_struct[i]);
    }
  }
  for (Uint32 i = 0; i < TOUCH_PARALLELISM; i++)
  {
    void *dummy_status;
    if (thread_ptr[i])
    {
      NdbThread_WaitFor(thread_ptr[i], &dummy_status);
      NdbThread_Destroy(&thread_ptr[i]);
    }
  }
}
Пример #14
0
Ndb_cluster_connection_impl::~Ndb_cluster_connection_impl()
{
  DBUG_ENTER("~Ndb_cluster_connection");
  TransporterFacade::stop_instance();
  if (m_connect_thread)
  {
    void *status;
    g_run_connect_thread= 0;
    NdbThread_WaitFor(m_connect_thread, &status);
    NdbThread_Destroy(&m_connect_thread);
    m_connect_thread= 0;
  }
  if (m_transporter_facade != 0)
  {
    delete m_transporter_facade;
    if (m_transporter_facade != TransporterFacade::theFacadeInstance)
      abort();
    TransporterFacade::theFacadeInstance= 0;
  }
  if (m_config_retriever)
  {
    delete m_config_retriever;
    m_config_retriever= NULL;
  }
  if (ndb_global_event_buffer_mutex != NULL)
  {
    NdbMutex_Destroy(ndb_global_event_buffer_mutex);
    ndb_global_event_buffer_mutex= NULL;
  }
#ifdef VM_TRACE
  if (ndb_print_state_mutex != NULL)
  {
    NdbMutex_Destroy(ndb_print_state_mutex);
    ndb_print_state_mutex= NULL;
  }
#endif
  if (m_name)
    free(m_name);

  DBUG_VOID_RETURN;
}
Пример #15
0
// Stop arbitrator thread via stop signal from the kernel
// or when exiting API program.
void
ArbitMgr::doStop(const Uint32* theData)
{
    DBUG_ENTER("ArbitMgr::doStop");
    ArbitSignal aSignal;
    NdbMutex_Lock(theThreadMutex);
    if (theThread != NULL) {
        aSignal.init(GSN_ARBIT_STOPORD, theData);
        if (theData == 0) {
            aSignal.data.code = StopExit;
        } else {
            aSignal.data.code = StopRequest;
        }
        sendSignalToThread(aSignal);
        void* value;
        NdbThread_WaitFor(theThread, &value);
        NdbThread_Destroy(&theThread);
        theState = StateInit;
    }
    NdbMutex_Unlock(theThreadMutex);
    DBUG_VOID_RETURN;
}
Пример #16
0
// Start arbitrator thread.  This is kernel request.
// First stop any previous thread since it is a left-over
// which was never used and which now has wrong ticket.
void
ArbitMgr::doStart(const Uint32* theData)
{
  ArbitSignal aSignal;
  NdbMutex_Lock(theThreadMutex);
  if (theThread != NULL) {
    aSignal.init(GSN_ARBIT_STOPORD, NULL);
    aSignal.data.code = StopRestart;
    sendSignalToThread(aSignal);
    void* value;
    NdbThread_WaitFor(theThread, &value);
    NdbThread_Destroy(&theThread);
    theState = StateInit;
    theInputFull = false;
  }
  aSignal.init(GSN_ARBIT_STARTREQ, theData);
  sendSignalToThread(aSignal);
  theThread = NdbThread_Create(
    runArbitMgr_C, (void**)this, 32768, "ndb_arbitmgr",
    NDB_THREAD_PRIO_HIGH);
  NdbMutex_Unlock(theThreadMutex);
}
Ndb_cluster_connection_impl::~Ndb_cluster_connection_impl()
{
  DBUG_ENTER("~Ndb_cluster_connection");
  if (m_transporter_facade != 0)
  {
    m_transporter_facade->stop_instance();
  }
  if (m_connect_thread)
  {
    void *status;
    m_run_connect_thread= 0;
    NdbThread_WaitFor(m_connect_thread, &status);
    NdbThread_Destroy(&m_connect_thread);
    m_connect_thread= 0;
  }
  if (m_transporter_facade != 0)
  {
    delete m_transporter_facade;
    m_transporter_facade = 0;
  }
  if (m_config_retriever)
  {
    delete m_config_retriever;
    m_config_retriever= NULL;
  }
#ifdef VM_TRACE
  if (ndb_print_state_mutex != NULL)
  {
    NdbMutex_Destroy(ndb_print_state_mutex);
    ndb_print_state_mutex= NULL;
  }
#endif
  if (m_name)
    free(m_name);

  NdbMutex_Lock(g_ndb_connection_mutex);
  if(--g_ndb_connection_count == 0){
    delete NdbDictionary::Column::FRAGMENT; 
    delete NdbDictionary::Column::FRAGMENT_FIXED_MEMORY;
    delete NdbDictionary::Column::FRAGMENT_VARSIZED_MEMORY;
    delete NdbDictionary::Column::ROW_COUNT;
    delete NdbDictionary::Column::COMMIT_COUNT;
    delete NdbDictionary::Column::ROW_SIZE;
    delete NdbDictionary::Column::RANGE_NO;
    delete NdbDictionary::Column::DISK_REF;
    delete NdbDictionary::Column::RECORDS_IN_RANGE;
    delete NdbDictionary::Column::ROWID;
    delete NdbDictionary::Column::ROW_GCI;
    delete NdbDictionary::Column::ANY_VALUE;
    NdbDictionary::Column::FRAGMENT= 0;
    NdbDictionary::Column::FRAGMENT_FIXED_MEMORY= 0;
    NdbDictionary::Column::FRAGMENT_VARSIZED_MEMORY= 0;
    NdbDictionary::Column::ROW_COUNT= 0;
    NdbDictionary::Column::COMMIT_COUNT= 0;
    NdbDictionary::Column::ROW_SIZE= 0;
    NdbDictionary::Column::RANGE_NO= 0;
    NdbDictionary::Column::DISK_REF= 0;
    NdbDictionary::Column::RECORDS_IN_RANGE= 0;
    NdbDictionary::Column::ROWID= 0;
    NdbDictionary::Column::ROW_GCI= 0;
    NdbDictionary::Column::ANY_VALUE= 0;

    delete NdbDictionary::Column::COPY_ROWID;
    NdbDictionary::Column::COPY_ROWID = 0;
  }
  NdbMutex_Unlock(g_ndb_connection_mutex);

  if (m_event_add_drop_mutex)
    NdbMutex_Destroy(m_event_add_drop_mutex);

  DBUG_VOID_RETURN;
}
Пример #18
0
Ndb_cluster_connection_impl::~Ndb_cluster_connection_impl()
{
  DBUG_ENTER("~Ndb_cluster_connection");

  if (m_first_ndb_object != 0)
  {
    g_eventLogger->warning("Deleting Ndb_cluster_connection with Ndb-object"
                           " not deleted");
    Ndb * p = m_first_ndb_object;
    printf("this: %p Ndb-object(s): ", (Ndb_cluster_connection*)this);
    while (p)
    {
      printf("%p ", p);
      p = p->theImpl->m_next_ndb_object;
    }
    printf("\n");
    fflush(stdout);
  }

  if (m_transporter_facade != 0)
  {
    m_transporter_facade->stop_instance();
  }
  if (m_globalDictCache)
  {
    delete m_globalDictCache;
  }
  if (m_connect_thread)
  {
    void *status;
    m_run_connect_thread= 0;
    NdbThread_WaitFor(m_connect_thread, &status);
    NdbThread_Destroy(&m_connect_thread);
    m_connect_thread= 0;
  }
  if (m_transporter_facade != 0)
  {
    delete m_transporter_facade;
    m_transporter_facade = 0;
  }
  if (m_config_retriever)
  {
    delete m_config_retriever;
    m_config_retriever= NULL;
  }

  NdbMutex_Lock(g_ndb_connection_mutex);
  if(--g_ndb_connection_count == 0)
  {
    NdbColumnImpl::destory_pseudo_columns();

#ifdef VM_TRACE
    NdbMutex_Destroy(ndb_print_state_mutex);
    ndb_print_state_mutex= NULL;
#endif

  }
  NdbMutex_Unlock(g_ndb_connection_mutex);

  if (m_event_add_drop_mutex)
    NdbMutex_Destroy(m_event_add_drop_mutex);
  m_event_add_drop_mutex = 0;

  if (m_new_delete_ndb_mutex)
    NdbMutex_Destroy(m_new_delete_ndb_mutex);
  m_new_delete_ndb_mutex = 0;
  
  if(m_multi_wait_group)
    delete m_multi_wait_group;
  m_multi_wait_group = 0;

  DBUG_VOID_RETURN;
}
Пример #19
0
CPCD::Monitor::~Monitor() {
  NdbThread_Destroy(&m_monitorThread);
  NdbCondition_Destroy(m_changeCondition);
  NdbMutex_Destroy(m_changeMutex);
}