summaryrefslogtreecommitdiff
path: root/ndb
diff options
context:
space:
mode:
authortomas@poseidon.ndb.mysql.com <>2005-07-14 18:02:33 +0200
committertomas@poseidon.ndb.mysql.com <>2005-07-14 18:02:33 +0200
commit9be420ee105609aade80f1c84767605ba4306e0f (patch)
treef92182c265c1d9ecac282bc59719e823b50cb81c /ndb
parent96a80fd2206df3df0df4a713e0a0c6cbf55fc61d (diff)
downloadmariadb-git-9be420ee105609aade80f1c84767605ba4306e0f.tar.gz
stilled mem leak in usage on getVersionString
added __LINE__ so systemErrorLab for better error printout
Diffstat (limited to 'ndb')
-rw-r--r--ndb/include/ndb_version.h.in12
-rw-r--r--ndb/include/util/version.h3
-rw-r--r--ndb/src/common/util/version.c12
-rw-r--r--ndb/src/kernel/blocks/qmgr/Qmgr.hpp4
-rw-r--r--ndb/src/kernel/blocks/qmgr/QmgrMain.cpp51
-rw-r--r--ndb/tools/restore/restore_main.cpp3
6 files changed, 48 insertions, 37 deletions
diff --git a/ndb/include/ndb_version.h.in b/ndb/include/ndb_version.h.in
index d7f43eae40a..826f5124407 100644
--- a/ndb/include/ndb_version.h.in
+++ b/ndb/include/ndb_version.h.in
@@ -36,8 +36,16 @@
#define MAKE_VERSION(A,B,C) (((A) << 16) | ((B) << 8) | ((C) << 0))
#define NDB_VERSION_D MAKE_VERSION(NDB_VERSION_MAJOR, NDB_VERSION_MINOR, NDB_VERSION_BUILD)
-
-#define NDB_VERSION_STRING (getVersionString(NDB_VERSION, NDB_VERSION_STATUS))
+#define NDB_VERSION_STRING_BUF_SZ 100
+#ifdef __cplusplus
+extern "C"
+#else
+extern
+#endif
+char ndb_version_string_buf[NDB_VERSION_STRING_BUF_SZ];
+#define NDB_VERSION_STRING (getVersionString(NDB_VERSION, NDB_VERSION_STATUS, \
+ ndb_version_string_buf, \
+ sizeof(ndb_version_string_buf)))
#define NDB_VERSION ndbGetOwnVersion()
diff --git a/ndb/include/util/version.h b/ndb/include/util/version.h
index 5459e44b818..62dc07d905a 100644
--- a/ndb/include/util/version.h
+++ b/ndb/include/util/version.h
@@ -30,7 +30,8 @@ extern "C" {
Uint32 makeVersion(Uint32 major, Uint32 minor, Uint32 build);
- const char* getVersionString(Uint32 version, const char * status);
+ const char* getVersionString(Uint32 version, const char * status,
+ char *buf, unsigned sz);
void ndbPrintVersion();
Uint32 ndbGetOwnVersion();
diff --git a/ndb/src/common/util/version.c b/ndb/src/common/util/version.c
index 7221dc48fa4..ba4bcf30516 100644
--- a/ndb/src/common/util/version.c
+++ b/ndb/src/common/util/version.c
@@ -38,22 +38,24 @@ Uint32 makeVersion(Uint32 major, Uint32 minor, Uint32 build) {
}
-const char * getVersionString(Uint32 version, const char * status) {
- char buff[100];
+char ndb_version_string_buf[NDB_VERSION_STRING_BUF_SZ];
+const char * getVersionString(Uint32 version, const char * status,
+ char *buf, unsigned sz)
+{
if (status && status[0] != 0)
- basestring_snprintf(buff, sizeof(buff),
+ basestring_snprintf(buf, sz,
"Version %d.%d.%d (%s)",
getMajor(version),
getMinor(version),
getBuild(version),
status);
else
- basestring_snprintf(buff, sizeof(buff),
+ basestring_snprintf(buf, sz,
"Version %d.%d.%d",
getMajor(version),
getMinor(version),
getBuild(version));
- return strdup(buff);
+ return buf;
}
typedef enum {
diff --git a/ndb/src/kernel/blocks/qmgr/Qmgr.hpp b/ndb/src/kernel/blocks/qmgr/Qmgr.hpp
index 0ff7cea6d9f..6d22ed0e509 100644
--- a/ndb/src/kernel/blocks/qmgr/Qmgr.hpp
+++ b/ndb/src/kernel/blocks/qmgr/Qmgr.hpp
@@ -257,8 +257,8 @@ private:
void hbReceivedLab(Signal* signal);
void sendCmRegrefLab(Signal* signal, BlockReference ref,
CmRegRef::ErrorCode);
- void systemErrorBecauseOtherNodeFailed(Signal* signal, NodeId);
- void systemErrorLab(Signal* signal,
+ void systemErrorBecauseOtherNodeFailed(Signal* signal, Uint32 line, NodeId);
+ void systemErrorLab(Signal* signal, Uint32 line,
const char* message = NULL);
void prepFailReqLab(Signal* signal);
void prepFailConfLab(Signal* signal);
diff --git a/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp b/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp
index da8596076ec..0337640d229 100644
--- a/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp
+++ b/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp
@@ -76,7 +76,7 @@ void Qmgr::execCM_HEARTBEAT(Signal* signal)
void Qmgr::execCM_NODEINFOREF(Signal* signal)
{
jamEntry();
- systemErrorLab(signal);
+ systemErrorLab(signal, __LINE__);
return;
}//Qmgr::execCM_NODEINFOREF()
@@ -121,7 +121,7 @@ void Qmgr::execCONTINUEB(Signal* signal)
default:
jam();
// ZCOULD_NOT_OCCUR_ERROR;
- systemErrorLab(signal);
+ systemErrorLab(signal, __LINE__);
return;
break;
}//switch
@@ -593,7 +593,7 @@ void Qmgr::execCM_REGCONF(Signal* signal)
jam();
char buf[128];
BaseString::snprintf(buf,sizeof(buf),"incompatible version own=0x%x other=0x%x, shutting down", NDB_VERSION, cmRegConf->presidentVersion);
- systemErrorLab(signal, buf);
+ systemErrorLab(signal, __LINE__, buf);
return;
}
@@ -688,7 +688,7 @@ void Qmgr::execCM_REGREF(Signal* signal)
switch (TrefuseReason) {
case CmRegRef::ZINCOMPATIBLE_VERSION:
jam();
- systemErrorLab(signal, "incompatible version, connection refused by running ndb node");
+ systemErrorLab(signal, __LINE__, "incompatible version, connection refused by running ndb node");
break;
case CmRegRef::ZBUSY:
case CmRegRef::ZBUSY_TO_PRES:
@@ -1751,7 +1751,7 @@ void Qmgr::execAPI_FAILCONF(Signal* signal)
if (failedNodePtr.p->rcv[0] == failedNodePtr.p->rcv[1]) {
jam();
- systemErrorLab(signal);
+ systemErrorLab(signal, __LINE__);
} else {
jam();
failedNodePtr.p->rcv[0] = 0;
@@ -1763,7 +1763,7 @@ void Qmgr::execAPI_FAILCONF(Signal* signal)
ndbout << "failedNodePtr.p->failState = "
<< (Uint32)(failedNodePtr.p->failState) << endl;
#endif
- systemErrorLab(signal);
+ systemErrorLab(signal, __LINE__);
}//if
return;
}//Qmgr::execAPI_FAILCONF()
@@ -1780,7 +1780,7 @@ void Qmgr::execNDB_FAILCONF(Signal* signal)
failedNodePtr.p->failState = NORMAL;
} else {
jam();
- systemErrorLab(signal);
+ systemErrorLab(signal, __LINE__);
}//if
if (cpresident == getOwnNodeId()) {
jam();
@@ -1931,20 +1931,13 @@ void Qmgr::execAPI_REGREQ(Signal* signal)
#endif
bool compatability_check;
- switch(getNodeInfo(apiNodePtr.i).getType()){
+ NodeInfo::NodeType type= getNodeInfo(apiNodePtr.i).getType();
+ switch(type){
case NodeInfo::API:
compatability_check = ndbCompatible_ndb_api(NDB_VERSION, version);
- if (!compatability_check)
- infoEvent("Connection attempt from api or mysqld id=%d with %s "
- "incompatible with %s", apiNodePtr.i,
- getVersionString(version,""), NDB_VERSION_STRING);
break;
case NodeInfo::MGM:
compatability_check = ndbCompatible_ndb_mgmt(NDB_VERSION, version);
- if (!compatability_check)
- infoEvent("Connection attempt from management server id=%d with %s "
- "incompatible with %s", apiNodePtr.i,
- getVersionString(version,""), NDB_VERSION_STRING);
break;
case NodeInfo::REP:
// compatability_check = ndbCompatible_ndb_api(NDB_VERSION, version);
@@ -1953,13 +1946,19 @@ void Qmgr::execAPI_REGREQ(Signal* signal)
case NodeInfo::INVALID:
default:
sendApiRegRef(signal, ref, ApiRegRef::WrongType);
- infoEvent("Invalid connection attempt with type %d",
- getNodeInfo(apiNodePtr.i).getType());
+ infoEvent("Invalid connection attempt with type %d", type);
return;
}
if (!compatability_check) {
jam();
+ char buf[NDB_VERSION_STRING_BUF_SZ];
+ infoEvent("Connection attempt from %s id=%d with %s "
+ "incompatible with %s",
+ type == NodeInfo::API ? "api or mysqld" : "management server",
+ apiNodePtr.i,
+ getVersionString(version,"",buf,sizeof(buf)),
+ NDB_VERSION_STRING);
apiNodePtr.p->phase = ZAPI_INACTIVE;
sendApiRegRef(signal, ref, ApiRegRef::UnsupportedVersion);
return;
@@ -2085,7 +2084,7 @@ void Qmgr::failReportLab(Signal* signal, Uint16 aFailedNode,
ptrCheckGuard(failedNodePtr, MAX_NODES, nodeRec);
if (failedNodePtr.i == getOwnNodeId()) {
jam();
- systemErrorLab(signal);
+ systemErrorLab(signal, __LINE__);
return;
}//if
@@ -2093,7 +2092,7 @@ void Qmgr::failReportLab(Signal* signal, Uint16 aFailedNode,
ptrCheckGuard(myNodePtr, MAX_NDB_NODES, nodeRec);
if (myNodePtr.p->phase != ZRUNNING) {
jam();
- systemErrorLab(signal);
+ systemErrorLab(signal, __LINE__);
return;
}//if
TnoFailedNodes = cnoFailedNodes;
@@ -2172,7 +2171,7 @@ void Qmgr::execPREP_FAILREQ(Signal* signal)
ptrCheckGuard(myNodePtr, MAX_NDB_NODES, nodeRec);
if (myNodePtr.p->phase != ZRUNNING) {
jam();
- systemErrorLab(signal);
+ systemErrorLab(signal, __LINE__);
return;
}//if
@@ -2675,7 +2674,7 @@ void Qmgr::execREAD_NODESREQ(Signal* signal)
ReadNodesConf::SignalLength, JBB);
}//Qmgr::execREAD_NODESREQ()
-void Qmgr::systemErrorBecauseOtherNodeFailed(Signal* signal,
+void Qmgr::systemErrorBecauseOtherNodeFailed(Signal* signal, Uint32 line,
NodeId failedNodeId) {
jam();
@@ -2687,11 +2686,11 @@ void Qmgr::systemErrorBecauseOtherNodeFailed(Signal* signal,
"Node was shutdown during startup because node %d failed",
failedNodeId);
- progError(__LINE__, ERR_SR_OTHERNODEFAILED, buf);
+ progError(line, ERR_SR_OTHERNODEFAILED, buf);
}
-void Qmgr::systemErrorLab(Signal* signal, const char * message)
+void Qmgr::systemErrorLab(Signal* signal, Uint32 line, const char * message)
{
jam();
// Broadcast that this node is failing to other nodes
@@ -2699,7 +2698,7 @@ void Qmgr::systemErrorLab(Signal* signal, const char * message)
// If it's known why shutdown occured
// an error message has been passed to this function
- progError(__LINE__, 0, message);
+ progError(line, 0, message);
return;
}//Qmgr::systemErrorLab()
@@ -2867,7 +2866,7 @@ Uint16 Qmgr::translateDynamicIdToNodeId(Signal* signal, UintR TdynamicId)
}//for
if (TtdiNodeId == ZNIL) {
jam();
- systemErrorLab(signal);
+ systemErrorLab(signal, __LINE__);
}//if
return TtdiNodeId;
}//Qmgr::translateDynamicIdToNodeId()
diff --git a/ndb/tools/restore/restore_main.cpp b/ndb/tools/restore/restore_main.cpp
index 84f9511fe2f..0c4419bb072 100644
--- a/ndb/tools/restore/restore_main.cpp
+++ b/ndb/tools/restore/restore_main.cpp
@@ -251,8 +251,9 @@ main(int argc, char** argv)
const BackupFormat::FileHeader & tmp = metaData.getFileHeader();
const Uint32 version = tmp.NdbVersion;
+ char buf[NDB_VERSION_STRING_BUF_SZ];
ndbout << "Ndb version in backup files: "
- << getVersionString(version, 0) << endl;
+ << getVersionString(version, 0, buf, sizeof(buf)) << endl;
/**
* check wheater we can restore the backup (right version).