/***************************************************************************** * ~Ndb(); * * Remark: Disconnect with the database. *****************************************************************************/ Ndb::~Ndb() { DBUG_ENTER("Ndb::~Ndb()"); DBUG_PRINT("enter",("this: 0x%lx", (long) this)); if (m_sys_tab_0) getDictionary()->removeTableGlobal(*m_sys_tab_0, 0); assert(theImpl->m_ev_op == 0); // user should return NdbEventOperation's for (NdbEventOperationImpl *op= theImpl->m_ev_op; op; op=op->m_next) { if (op->m_state == NdbEventOperation::EO_EXECUTING && op->stop()) g_eventLogger.error("stopping NdbEventOperation failed in Ndb destructor"); op->m_magic_number= 0; } doDisconnect(); /* Disconnect from transporter to stop signals from coming in */ if (theImpl->m_transporter_facade != NULL && theNdbBlockNumber > 0) { theImpl->m_transporter_facade->close(theNdbBlockNumber, theFirstTransId); } delete theEventBuffer; releaseTransactionArrays(); delete []theConnectionArray; if(theCommitAckSignal != NULL) { delete theCommitAckSignal; theCommitAckSignal = NULL; } delete theImpl; #ifdef POORMANSPURIFY #ifdef POORMANSGUI ndbout << "cnewSignals=" << cnewSignals << endl; ndbout << "cfreeSignals=" << cfreeSignals << endl; ndbout << "cgetSignals=" << cgetSignals << endl; ndbout << "creleaseSignals=" << creleaseSignals << endl; #endif // Poor mans purifier assert(cnewSignals == cfreeSignals); assert(cgetSignals == creleaseSignals); #endif DBUG_VOID_RETURN; }
/***************************************************************************** * ~Ndb(); * * Remark: Disconnect with the database. *****************************************************************************/ Ndb::~Ndb() { DBUG_ENTER("Ndb::~Ndb()"); DBUG_PRINT("enter",("Ndb::~Ndb this: 0x%lx",(long) this)); doDisconnect(); if (TransporterFacade::instance() != NULL && theNdbBlockNumber > 0){ TransporterFacade::instance()->close(theNdbBlockNumber, theFirstTransId); } releaseTransactionArrays(); delete []theConnectionArray; if(theCommitAckSignal != NULL){ delete theCommitAckSignal; theCommitAckSignal = NULL; } delete theImpl; /** * This sleep is to make sure that the transporter * send thread will come in and send any * signal buffers that this thread may have allocated. * If that doesn't happen an error will occur in OSE * when trying to restore a signal buffer allocated by a thread * that have been killed. */ #ifdef NDB_OSE NdbSleep_MilliSleep(50); #endif #ifdef POORMANSPURIFY #ifdef POORMANSGUI ndbout << "cnewSignals=" << cnewSignals << endl; ndbout << "cfreeSignals=" << cfreeSignals << endl; ndbout << "cgetSignals=" << cgetSignals << endl; ndbout << "creleaseSignals=" << creleaseSignals << endl; #endif // Poor mans purifier assert(cnewSignals == cfreeSignals); assert(cgetSignals == creleaseSignals); #endif DBUG_VOID_RETURN; }
/***************************************************************************** * ~Ndb(); * * Remark: Disconnect with the database. *****************************************************************************/ Ndb::~Ndb() { DBUG_ENTER("Ndb::~Ndb()"); DBUG_PRINT("enter",("this: 0x%lx", (long) this)); if (m_sys_tab_0) getDictionary()->removeTableGlobal(*m_sys_tab_0, 0); if (theImpl->m_ev_op != 0) { g_eventLogger->warning("Deleting Ndb-object with NdbEventOperation still" " active"); printf("this: %p NdbEventOperation(s): ", this); for (NdbEventOperationImpl *op= theImpl->m_ev_op; op; op=op->m_next) { printf("%p ", op); } printf("\n"); fflush(stdout); } assert(theImpl->m_ev_op == 0); // user should return NdbEventOperation's for (NdbEventOperationImpl *op= theImpl->m_ev_op; op; op=op->m_next) { if (op->m_state == NdbEventOperation::EO_EXECUTING && op->stop()) g_eventLogger->error("stopping NdbEventOperation failed in Ndb destructor"); op->m_magic_number= 0; } doDisconnect(); /* Disconnect from transporter to stop signals from coming in */ theImpl->close(); delete theEventBuffer; releaseTransactionArrays(); delete []theConnectionArray; delete []theConnectionArrayLast; if(theCommitAckSignal != NULL){ delete theCommitAckSignal; theCommitAckSignal = NULL; } theImpl->m_ndb_cluster_connection.unlink_ndb_object(this); delete theImpl; #ifdef POORMANSPURIFY #ifdef POORMANSGUI ndbout << "cnewSignals=" << cnewSignals << endl; ndbout << "cfreeSignals=" << cfreeSignals << endl; ndbout << "cgetSignals=" << cgetSignals << endl; ndbout << "creleaseSignals=" << creleaseSignals << endl; #endif // Poor mans purifier assert(cnewSignals == cfreeSignals); assert(cgetSignals == creleaseSignals); #endif DBUG_VOID_RETURN; }
/****************************************************************************** * int init( int aNrOfCon, int aNrOfOp ); * * Return Value: Return 0 : init was successful. * Return -1: In all other case. * Parameters: aNrOfCon : Number of connections offered to the application. * aNrOfOp : Number of operations offered to the application. * Remark: Create pointers and idle list Synchronous. ****************************************************************************/ int Ndb::init(int aMaxNoOfTransactions) { DBUG_ENTER("Ndb::init"); int i; int aNrOfCon; int aNrOfOp; int tMaxNoOfTransactions; NdbApiSignal* tSignal[16]; // Initiate free list of 16 signal objects if (theInitState != NotInitialised) { switch(theInitState){ case InitConfigError: theError.code = 4117; break; default: theError.code = 4104; break; } DBUG_RETURN(-1); }//if theInitState = StartingInit; TransporterFacade * theFacade = theImpl->m_transporter_facade; theEventBuffer->m_mutex = theFacade->theMutexPtr; const Uint32 tRef = theImpl->open(theFacade); if (tRef == 0) { theError.code = 4105; DBUG_RETURN(-1); // no more free blocknumbers }//if Uint32 nodeId = refToNode(tRef); theNdbBlockNumber = refToBlock(tRef); if (nodeId > 0) { connected(Uint32(tRef)); } /* Init cached min node version */ theFacade->lock_mutex(); theCachedMinDbNodeVersion = theFacade->getMinDbNodeVersion(); theFacade->unlock_mutex(); theDictionary->setTransporter(this, theFacade); aNrOfCon = theImpl->theNoOfDBnodes; aNrOfOp = 2*theImpl->theNoOfDBnodes; // Create connection object in a linked list if((createConIdleList(aNrOfCon)) == -1){ theError.code = 4000; goto error_handler; } // Create operations in a linked list if((createOpIdleList(aNrOfOp)) == -1){ theError.code = 4000; goto error_handler; } tMaxNoOfTransactions = aMaxNoOfTransactions; theMaxNoOfTransactions = tMaxNoOfTransactions; theRemainingStartTransactions= tMaxNoOfTransactions; thePreparedTransactionsArray = new NdbTransaction* [tMaxNoOfTransactions]; theSentTransactionsArray = new NdbTransaction* [tMaxNoOfTransactions]; theCompletedTransactionsArray = new NdbTransaction* [tMaxNoOfTransactions]; if ((thePreparedTransactionsArray == NULL) || (theSentTransactionsArray == NULL) || (theCompletedTransactionsArray == NULL)) { goto error_handler; }//if for (i = 0; i < tMaxNoOfTransactions; i++) { thePreparedTransactionsArray[i] = NULL; theSentTransactionsArray[i] = NULL; theCompletedTransactionsArray[i] = NULL; }//for for (i = 0; i < 16; i++){ tSignal[i] = getSignal(); if(tSignal[i] == NULL) { theError.code = 4000; goto error_handler; } } for (i = 0; i < 16; i++) releaseSignal(tSignal[i]); theInitState = Initialised; DBUG_RETURN(0); error_handler: ndbout << "error_handler" << endl; releaseTransactionArrays(); delete theDictionary; theImpl->close(); DBUG_RETURN(-1); }