Commit 4fd8584f authored by unknown's avatar unknown

Bug#19047, not start the event thread when ndb_mgm is running in executing (-e) thread.


ndb/src/mgmclient/CommandInterpreter.cpp:
  Not start event thread when ndb_mgm client is running in executing (-e) mode.
ndb/src/mgmclient/main.cpp:
  Not start event thread when ndb_mgm is runing in executing (-e) mode.
ndb/src/mgmclient/ndb_mgmclient.hpp:
  Not start event thread when ndb_mgm is running in executing (-e) mode.
parent fe37a3bf
......@@ -55,11 +55,11 @@ class CommandInterpreter {
*
* @return true until quit/bye/exit has been typed
*/
int execute(const char *_line, int _try_reconnect=-1, int *error= 0);
int execute(const char *_line, int _try_reconnect=-1, bool interactive=1, int *error= 0);
private:
void printError();
int execute_impl(const char *_line);
int execute_impl(const char *_line, bool interactive=1);
/**
* Analyse the command line, after the first token.
......@@ -99,7 +99,7 @@ class CommandInterpreter {
*/
void executeHelp(char* parameters);
void executeShow(char* parameters);
void executeConnect(char* parameters);
void executeConnect(char* parameters, bool interactive);
void executePurge(char* parameters);
int executeShutdown(char* parameters);
void executeRun(char* parameters);
......@@ -137,7 +137,7 @@ class CommandInterpreter {
void executeCpc(char * parameters);
public:
bool connect();
bool connect(bool interactive);
bool disconnect();
/**
......@@ -198,9 +198,9 @@ Ndb_mgmclient::~Ndb_mgmclient()
{
delete m_cmd;
}
int Ndb_mgmclient::execute(const char *_line, int _try_reconnect, int *error)
int Ndb_mgmclient::execute(const char *_line, int _try_reconnect, bool interactive, int *error)
{
return m_cmd->execute(_line,_try_reconnect,error);
return m_cmd->execute(_line,_try_reconnect,interactive, error);
}
int
Ndb_mgmclient::disconnect()
......@@ -246,7 +246,7 @@ extern "C" {
#include <util/InputStream.hpp>
#include <util/OutputStream.hpp>
int Ndb_mgmclient::execute(int argc, char** argv, int _try_reconnect, int *error)
int Ndb_mgmclient::execute(int argc, char** argv, int _try_reconnect, bool interactive, int *error)
{
if (argc <= 0)
return 0;
......@@ -255,7 +255,7 @@ int Ndb_mgmclient::execute(int argc, char** argv, int _try_reconnect, int *error
{
_line.appfmt(" %s", argv[i]);
}
return m_cmd->execute(_line.c_str(),_try_reconnect, error);
return m_cmd->execute(_line.c_str(),_try_reconnect, interactive, error);
}
/*****************************************************************************
......@@ -400,7 +400,7 @@ CommandInterpreter::CommandInterpreter(const char *_host,int verbose)
{
m_constr= _host;
m_connected= false;
m_event_thread= 0;
m_event_thread= NULL;
try_reconnect = 0;
m_print_mutex= NdbMutex_Create();
#ifdef HAVE_GLOBAL_REPLICATION
......@@ -495,7 +495,7 @@ event_thread_run(void* p)
}
bool
CommandInterpreter::connect()
CommandInterpreter::connect(bool interactive)
{
DBUG_ENTER("CommandInterpreter::connect");
......@@ -507,11 +507,13 @@ CommandInterpreter::connect()
ndbout_c("Cannot create handle to management server.");
exit(-1);
}
if (interactive) {
m_mgmsrv2 = ndb_mgm_create_handle();
if(m_mgmsrv2 == NULL) {
ndbout_c("Cannot create 2:nd handle to management server.");
exit(-1);
}
}
if (ndb_mgm_set_connectstring(m_mgmsrv, m_constr))
{
......@@ -524,6 +526,7 @@ CommandInterpreter::connect()
const char *host= ndb_mgm_get_connected_host(m_mgmsrv);
unsigned port= ndb_mgm_get_connected_port(m_mgmsrv);
if (interactive) {
BaseString constr;
constr.assfmt("%s:%d",host,port);
if(!ndb_mgm_set_connectstring(m_mgmsrv2, constr.c_str()) &&
......@@ -531,7 +534,7 @@ CommandInterpreter::connect()
{
DBUG_PRINT("info",("2:ndb connected to Management Server ok at: %s:%d",
host, port));
assert(m_event_thread == 0);
assert(m_event_thread == NULL);
assert(do_event_thread == 0);
do_event_thread= 0;
struct event_thread_param p;
......@@ -542,7 +545,7 @@ CommandInterpreter::connect()
32768,
"CommandInterpreted_event_thread",
NDB_THREAD_PRIO_LOW);
if (m_event_thread != 0)
if (m_event_thread)
{
DBUG_PRINT("info",("Thread created ok, waiting for started..."));
int iter= 1000; // try for 30 seconds
......@@ -550,7 +553,7 @@ CommandInterpreter::connect()
iter-- > 0)
NdbSleep_MilliSleep(30);
}
if (m_event_thread == 0 ||
if (m_event_thread == NULL ||
do_event_thread == 0 ||
do_event_thread == -1)
{
......@@ -581,6 +584,7 @@ CommandInterpreter::connect()
ndb_mgm_get_latest_error(m_mgmsrv2),
ndb_mgm_get_latest_error_msg(m_mgmsrv2));
}
}
m_connected= true;
DBUG_PRINT("info",("Connected to Management Server at: %s:%d", host, port));
if (m_verbose)
......@@ -602,7 +606,7 @@ CommandInterpreter::disconnect()
do_event_thread= 0;
NdbThread_WaitFor(m_event_thread, &res);
NdbThread_Destroy(&m_event_thread);
m_event_thread= 0;
m_event_thread= NULL;
ndb_mgm_destroy_handle(&m_mgmsrv2);
}
if (m_connected)
......@@ -618,11 +622,11 @@ CommandInterpreter::disconnect()
int
CommandInterpreter::execute(const char *_line, int _try_reconnect,
int *error)
bool interactive, int *error)
{
if (_try_reconnect >= 0)
try_reconnect=_try_reconnect;
int result= execute_impl(_line);
int result= execute_impl(_line, interactive);
if (error)
*error= m_error;
......@@ -637,7 +641,7 @@ invalid_command(const char *cmd)
}
int
CommandInterpreter::execute_impl(const char *_line)
CommandInterpreter::execute_impl(const char *_line, bool interactive)
{
DBUG_ENTER("CommandInterpreter::execute_impl");
DBUG_PRINT("enter",("line=\"%s\"",_line));
......@@ -686,7 +690,7 @@ CommandInterpreter::execute_impl(const char *_line)
DBUG_RETURN(true);
}
else if (strcasecmp(firstToken, "CONNECT") == 0) {
executeConnect(allAfterFirstToken);
executeConnect(allAfterFirstToken, interactive);
DBUG_RETURN(true);
}
else if (strcasecmp(firstToken, "SLEEP") == 0) {
......@@ -701,7 +705,7 @@ CommandInterpreter::execute_impl(const char *_line)
DBUG_RETURN(false);
}
if (!connect())
if (!connect(interactive))
DBUG_RETURN(true);
if (strcasecmp(firstToken, "SHOW") == 0) {
......@@ -1312,13 +1316,13 @@ CommandInterpreter::executeShow(char* parameters)
}
void
CommandInterpreter::executeConnect(char* parameters)
CommandInterpreter::executeConnect(char* parameters, bool interactive)
{
disconnect();
if (!emptyString(parameters)) {
m_constr= BaseString(parameters).trim().c_str();
}
connect();
connect(interactive);
}
//*****************************************************************************
......
......@@ -121,7 +121,7 @@ read_and_execute(int _try_reconnect)
line_read= strdup(linebuffer);
}
#endif
return com->execute(line_read,_try_reconnect);
return com->execute(line_read, _try_reconnect, 1);
}
int main(int argc, char** argv){
......@@ -163,7 +163,7 @@ int main(int argc, char** argv){
}
else
{
com->execute(opt_execute_str,_try_reconnect, &ret);
com->execute(opt_execute_str,_try_reconnect, 0, &ret);
}
delete com;
......
......@@ -23,8 +23,8 @@ class Ndb_mgmclient
public:
Ndb_mgmclient(const char*,int verbose=0);
~Ndb_mgmclient();
int execute(const char *_line, int _try_reconnect=-1, int *error= 0);
int execute(int argc, char** argv, int _try_reconnect=-1, int *error= 0);
int execute(const char *_line, int _try_reconnect=-1, bool interactive=1, int *error= 0);
int execute(int argc, char** argv, int _try_reconnect=-1, bool interactive=1, int *error= 0);
int disconnect();
private:
CommandInterpreter *m_cmd;
......
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