fixed bug/compiler warning

    rewrote safer
    added return value to shutdown
    nicer printouts
    removed exit at shutdown
parent 91aec870
......@@ -174,7 +174,7 @@ Logger::addHandler(const BaseString &logstring) {
logstring.split(logdest, ";");
for(i = 0; i < logdest.size(); i++) {
DBUG_PRINT("info",("adding: %s",logdest[i]));
DBUG_PRINT("info",("adding: %s",logdest[i].c_str()));
Vector<BaseString> v_type_args;
logdest[i].split(v_type_args, ":", 2);
......
......@@ -298,13 +298,21 @@ char *
LocalConfig::makeConnectString(char *buf, int sz)
{
int p= BaseString::snprintf(buf,sz,"nodeid=%d", _ownNodeId);
for (int i = 0; (i < ids.size()) && (sz-p > 0); i++)
{
if (ids[i].type != MgmId_TCP)
continue;
p+=BaseString::snprintf(buf+p,sz-p,",%s:%d",
ids[i].name.c_str(), ids[i].port);
}
if (p < sz)
for (unsigned i = 0; i < ids.size(); i++)
{
if (ids[i].type != MgmId_TCP)
continue;
int new_p= p+BaseString::snprintf(buf+p,sz-p,",%s:%d",
ids[i].name.c_str(), ids[i].port);
if (new_p < sz)
p= new_p;
else
{
buf[p]= 0;
break;
}
}
buf[sz-1]=0;
return buf;
}
......
......@@ -97,7 +97,7 @@ class CommandInterpreter {
void executeShow(char* parameters);
void executeConnect(char* parameters);
void executePurge(char* parameters);
void executeShutdown(char* parameters);
int executeShutdown(char* parameters);
void executeRun(char* parameters);
void executeInfo(char* parameters);
void executeClusterLog(char* parameters);
......@@ -523,7 +523,7 @@ CommandInterpreter::execute_impl(const char *_line)
DBUG_RETURN(true);
}
else if (strcasecmp(firstToken, "SHUTDOWN") == 0) {
executeShutdown(allAfterFirstToken);
m_error= executeShutdown(allAfterFirstToken);
DBUG_RETURN(true);
}
else if (strcasecmp(firstToken, "CLUSTERLOG") == 0){
......@@ -854,23 +854,23 @@ CommandInterpreter::executeHelp(char* parameters)
* SHUTDOWN
*****************************************************************************/
void
int
CommandInterpreter::executeShutdown(char* parameters)
{
ndb_mgm_cluster_state *state = ndb_mgm_get_status(m_mgmsrv);
if(state == NULL) {
ndbout_c("Could not get status");
printError();
return;
return 1;
}
NdbAutoPtr<char> ap1((char*)state);
int result = 0;
result = ndb_mgm_stop(m_mgmsrv, 0, 0);
if (result < 0) {
ndbout << "Shutdown failed." << endl;
ndbout << "Shutdown off NDB Cluster storage node(s) failed." << endl;
printError();
return;
return result;
}
ndbout << result << " NDB Cluster storage node(s) have shutdown." << endl;
......@@ -885,21 +885,23 @@ CommandInterpreter::executeShutdown(char* parameters)
ndbout << "Unable to locate management server, "
<< "shutdown manually with <id> STOP"
<< endl;
return;
return 1;
}
}
}
result = 0;
result = ndb_mgm_stop(m_mgmsrv, 1, &mgm_id);
if (result <= 0) {
ndbout << "Shutdown failed." << endl;
ndbout << "Shutdown of NDB Cluster management server failed." << endl;
printError();
return;
if (result == 0)
return 1;
return result;
}
connected = false;
ndbout << "NDB Cluster management server shutdown." << endl;
exit(0);
return 0;
}
/*****************************************************************************
......
......@@ -128,7 +128,7 @@ int Ndb_cluster_connection::connect(int reconnect)
new ConfigRetriever(m_connect_string, NDB_VERSION, NODE_TYPE_API);
if (m_config_retriever->hasError())
{
printf("Could not connect initialize handle to management server",
printf("Could not connect initialize handle to management server: %s",
m_config_retriever->getErrorString());
DBUG_RETURN(-1);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment