Esempio n. 1
0
// The "choose me" signal from a candidate.
void
ArbitMgr::doChoose(const Uint32* theData)
{
    ArbitSignal aSignal;
    aSignal.init(GSN_ARBIT_CHOOSEREQ, theData);
    sendSignalToThread(aSignal);
}
Esempio n. 2
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;
}
Esempio n. 3
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);
}
Esempio n. 4
0
void
ArbitMgr::sendSignalToThread(ArbitSignal& aSignal)
{
#ifdef DEBUG_ARBIT
    char buf[17] = "";
    ndbout << "arbit recv: ";
    ndbout << " gsn=" << aSignal.gsn;
    ndbout << " send=" << aSignal.data.sender;
    ndbout << " code=" << aSignal.data.code;
    ndbout << " node=" << aSignal.data.node;
    ndbout << " ticket=" << aSignal.data.ticket.getText(buf, sizeof(buf));
    ndbout << " mask=" << aSignal.data.mask.getText(buf, sizeof(buf));
    ndbout << endl;
#endif
    aSignal.setTimestamp();       // signal arrival time
    NdbMutex_Lock(theInputMutex);
    while (theInputFull) {
        NdbCondition_WaitTimeout(theInputCond, theInputMutex, 1000);
    }
    theInputBuffer = aSignal;
    theInputFull = true;
    NdbCondition_Signal(theInputCond);
    NdbMutex_Unlock(theInputMutex);
}