summaryrefslogtreecommitdiff
path: root/ndb/src/ndbapi/ClusterMgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ndb/src/ndbapi/ClusterMgr.cpp')
-rw-r--r--ndb/src/ndbapi/ClusterMgr.cpp46
1 files changed, 30 insertions, 16 deletions
diff --git a/ndb/src/ndbapi/ClusterMgr.cpp b/ndb/src/ndbapi/ClusterMgr.cpp
index b9947fcf0e7..e10b2e1d82c 100644
--- a/ndb/src/ndbapi/ClusterMgr.cpp
+++ b/ndb/src/ndbapi/ClusterMgr.cpp
@@ -15,6 +15,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <ndb_global.h>
+#include <my_pthread.h>
#include <ndb_limits.h>
#include <ndb_version.h>
@@ -36,6 +37,8 @@
#include <mgmapi_configuration.hpp>
#include <mgmapi_config_parameters.h>
+int global_flag_send_heartbeat_now= 0;
+
// Just a C wrapper for threadMain
extern "C"
void*
@@ -64,7 +67,8 @@ ClusterMgr::ClusterMgr(TransporterFacade & _facade):
{
ndbSetOwnVersion();
clusterMgrThreadMutex = NdbMutex_Create();
- noOfConnectedNodes = 0;
+ noOfConnectedNodes= 0;
+ theClusterMgrThread= 0;
}
ClusterMgr::~ClusterMgr(){
@@ -137,20 +141,21 @@ ClusterMgr::startThread() {
void
ClusterMgr::doStop( ){
+ DBUG_ENTER("ClusterMgr::doStop");
NdbMutex_Lock(clusterMgrThreadMutex);
-
if(theStop){
NdbMutex_Unlock(clusterMgrThreadMutex);
- return;
+ DBUG_VOID_RETURN;
}
-
void *status;
theStop = 1;
-
- NdbThread_WaitFor(theClusterMgrThread, &status);
- NdbThread_Destroy(&theClusterMgrThread);
-
+ if (theClusterMgrThread) {
+ NdbThread_WaitFor(theClusterMgrThread, &status);
+ NdbThread_Destroy(&theClusterMgrThread);
+ theClusterMgrThread= 0;
+ }
NdbMutex_Unlock(clusterMgrThreadMutex);
+ DBUG_VOID_RETURN;
}
void
@@ -174,6 +179,9 @@ ClusterMgr::threadMain( ){
/**
* Start of Secure area for use of Transporter
*/
+ int send_heartbeat_now= global_flag_send_heartbeat_now;
+ global_flag_send_heartbeat_now= 0;
+
theFacade.lock_mutex();
for (int i = 1; i < MAX_NODES; i++){
/**
@@ -196,12 +204,16 @@ ClusterMgr::threadMain( ){
}
theNode.hbCounter += timeSlept;
- if (theNode.hbCounter >= theNode.hbFrequency){
+ if (theNode.hbCounter >= theNode.hbFrequency ||
+ send_heartbeat_now) {
/**
* It is now time to send a new Heartbeat
*/
- theNode.hbSent++;
- theNode.hbCounter = 0;
+ if (theNode.hbCounter >= theNode.hbFrequency) {
+ theNode.hbSent++;
+ theNode.hbCounter = 0;
+ }
+
/**
* If the node is of type REP,
* then the receiver of the signal should be API_CLUSTERMGR
@@ -440,13 +452,11 @@ ClusterMgr::reportNodeFailed(NodeId nodeId){
theNode.nfCompleteRep = false;
if(noOfConnectedNodes == 0){
- Uint32 theData[1];
- NFCompleteRep * rep = (NFCompleteRep *)&theData[0];
-
+ NFCompleteRep rep;
for(Uint32 i = 1; i<MAX_NODES; i++){
if(theNodes[i].defined && theNodes[i].nfCompleteRep == false){
- rep->failedNodeId = i;
- execNF_COMPLETEREP(theData);
+ rep.failedNodeId = i;
+ execNF_COMPLETEREP((Uint32*)&rep);
}
}
}
@@ -524,6 +534,7 @@ ArbitMgr::doChoose(const Uint32* theData)
void
ArbitMgr::doStop(const Uint32* theData)
{
+ DBUG_ENTER("ArbitMgr::doStop");
ArbitSignal aSignal;
NdbMutex_Lock(theThreadMutex);
if (theThread != NULL) {
@@ -540,6 +551,7 @@ ArbitMgr::doStop(const Uint32* theData)
theState = StateInit;
}
NdbMutex_Unlock(theThreadMutex);
+ DBUG_VOID_RETURN;
}
// private methods
@@ -548,7 +560,9 @@ extern "C"
void*
runArbitMgr_C(void* me)
{
+ my_thread_init();
((ArbitMgr*) me)->threadMain();
+ my_thread_end();
NdbThread_Exit(0);
return NULL;
}