From 1778ac4fcf27ba41aa7e53b606ab50127ba95f8c Mon Sep 17 00:00:00 2001 From: "pekka@mysql.com" <> Date: Sun, 10 Oct 2004 17:38:14 +0200 Subject: [PATCH] NDB ndb_mgm: fix dump and signal log (more to do) --- ndb/include/mgmapi/mgmapi.h | 11 ++- .../debugger/signaldata/SignalNames.cpp | 2 + ndb/src/mgmapi/mgmapi.cpp | 9 +- ndb/src/mgmclient/CommandInterpreter.cpp | 83 +++++-------------- 4 files changed, 38 insertions(+), 67 deletions(-) diff --git a/ndb/include/mgmapi/mgmapi.h b/ndb/include/mgmapi/mgmapi.h index 44307c3e73c..d3a320123a3 100644 --- a/ndb/include/mgmapi/mgmapi.h +++ b/ndb/include/mgmapi/mgmapi.h @@ -122,7 +122,10 @@ extern "C" { /* Service errors - Single User Mode */ NDB_MGM_COULD_NOT_ENTER_SINGLE_USER_MODE = 4001, - NDB_MGM_COULD_NOT_EXIT_SINGLE_USER_MODE = 4002 + NDB_MGM_COULD_NOT_EXIT_SINGLE_USER_MODE = 4002, + + /* Usage errors */ + NDB_MGM_USAGE_ERROR = 5001 }; struct Ndb_Mgm_Error_Msg { @@ -158,7 +161,11 @@ extern "C" { { NDB_MGM_COULD_NOT_ENTER_SINGLE_USER_MODE, "Could not enter single user mode" }, { NDB_MGM_COULD_NOT_EXIT_SINGLE_USER_MODE, - "Could not exit single user mode" } + "Could not exit single user mode" }, + + /* Usage errors */ + { NDB_MGM_USAGE_ERROR, + "Usage error" } }; const int ndb_mgm_noOfErrorMsgs = diff --git a/ndb/src/common/debugger/signaldata/SignalNames.cpp b/ndb/src/common/debugger/signaldata/SignalNames.cpp index 9d4d5bdf6f5..9228e305677 100644 --- a/ndb/src/common/debugger/signaldata/SignalNames.cpp +++ b/ndb/src/common/debugger/signaldata/SignalNames.cpp @@ -446,6 +446,8 @@ const GsnName SignalNames [] = { ,{ GSN_STOP_REQ, "STOP_REQ" } ,{ GSN_STOP_REF, "STOP_REF" } + ,{ GSN_API_VERSION_REQ, "API_VERSION_REQ" } + ,{ GSN_API_VERSION_CONF, "API_VERSION_CONF" } ,{ GSN_ABORT_ALL_REQ, "ABORT_ALL_REQ" } ,{ GSN_ABORT_ALL_REF, "ABORT_ALL_REF" } diff --git a/ndb/src/mgmapi/mgmapi.cpp b/ndb/src/mgmapi/mgmapi.cpp index fccd5c7983b..837876503f6 100644 --- a/ndb/src/mgmapi/mgmapi.cpp +++ b/ndb/src/mgmapi/mgmapi.cpp @@ -1153,11 +1153,14 @@ ndb_mgm_dump_state(NdbMgmHandle handle, int nodeId, int* _args, CHECK_CONNECTED(handle, -1); char buf[256]; - char buf2[6]; buf[0] = 0; for (int i = 0; i < _num_args; i++){ - snprintf(buf2, 6, "%d ", _args[i]); - strncat(buf, buf2, 256); + unsigned n = strlen(buf); + if (n + 20 > sizeof(buf)) { + SET_ERROR(handle, NDB_MGM_USAGE_ERROR, "arguments too long"); + return -1; + } + sprintf(buf + n, "%s%d", i ? " " : "", _args[i]); } Properties args; diff --git a/ndb/src/mgmclient/CommandInterpreter.cpp b/ndb/src/mgmclient/CommandInterpreter.cpp index 7560a59a1ef..b03a4f8a419 100644 --- a/ndb/src/mgmclient/CommandInterpreter.cpp +++ b/ndb/src/mgmclient/CommandInterpreter.cpp @@ -1363,36 +1363,29 @@ CommandInterpreter::executeLog(int processId, if (! parseBlockSpecification(parameters, blocks)) { return; } - int len=0; + int len=1; Uint32 i; for(i=0; i ap1(blockNames); + blockNames[0] = 0; for(i=0; i blocks; - if (! parseBlockSpecification(parameters, blocks)) { - return; - } - -#if 0 - int result = _mgmtSrvr.setSignalLoggingMode(processId, MgmtSrvr::In, blocks); - if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; - } -#endif + ndbout << "Command LOGIN not implemented." << endl; } //***************************************************************************** @@ -1420,19 +1403,7 @@ void CommandInterpreter::executeLogOut(int /*processId*/, const char* parameters, bool /*all*/) { - Vector blocks; - if (! parseBlockSpecification(parameters, blocks)) { - return; - } - - -#if 0 - int result = _mgmtSrvr.setSignalLoggingMode(processId, MgmtSrvr::Out, - blocks); - if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; - } -#endif + ndbout << "Command LOGOUT not implemented." << endl; } //***************************************************************************** @@ -1441,57 +1412,45 @@ void CommandInterpreter::executeLogOff(int /*processId*/, const char* parameters, bool /*all*/) { - Vector blocks; - if (! parseBlockSpecification(parameters, blocks)) { - return; - } - - -#if 0 - int result = _mgmtSrvr.setSignalLoggingMode(processId, MgmtSrvr::Off, - blocks); - if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; - } -#endif + ndbout << "Command LOGOFF not implemented." << endl; } //***************************************************************************** //***************************************************************************** void -CommandInterpreter::executeTestOn(int /*processId*/, +CommandInterpreter::executeTestOn(int processId, const char* parameters, bool /*all*/) { if (! emptyString(parameters)) { ndbout << "No parameters expected to this command." << endl; return; } - -#if 0 - int result = _mgmtSrvr.startSignalTracing(processId); + connect(); + struct ndb_mgm_reply reply; + int result = ndb_mgm_start_signallog(m_mgmsrv, processId, &reply); if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; + ndbout_c("Execute TESTON failed."); + printError(); } -#endif } //***************************************************************************** //***************************************************************************** void -CommandInterpreter::executeTestOff(int /*processId*/, +CommandInterpreter::executeTestOff(int processId, const char* parameters, bool /*all*/) { if (! emptyString(parameters)) { ndbout << "No parameters expected to this command." << endl; return; } - -#if 0 - int result = _mgmtSrvr.stopSignalTracing(processId); + connect(); + struct ndb_mgm_reply reply; + int result = ndb_mgm_stop_signallog(m_mgmsrv, processId, &reply); if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; + ndbout_c("Execute TESTOFF failed."); + printError(); } -#endif }