Commit a5cc93b9 authored by unknown's avatar unknown

Add (optional) endian parameter to 'get nodeid' to warn on endian conflicts.


ndb/src/mgmapi/mgmapi.cpp:
  Send an extra (optional) parameter to 'get nodeid' to detect potential endianness conflicts.
  
  endian: big
  endian: small
  
  Server will deny our nodeid request if we're not compatible.
  
  If parameter is not specified, we behave how we used to (work or fail).
ndb/src/mgmsrv/Services.cpp:
  Add extra (optional) parameter to 'get nodeid' to detect potential endianness conflicts.
  
  endian: big
  endian: little
  
  we will deny the nodeid request if the endian parameter is provided and the endian doesn't match.
  
  This should preserve compatibility with all clients.
BitKeeper/etc/logging_ok:
  Logging to logging@openlogging.org accepted
parent f8cdf570
...@@ -192,6 +192,7 @@ serg@sergbook.mylan ...@@ -192,6 +192,7 @@ serg@sergbook.mylan
serg@sergbook.mysql.com serg@sergbook.mysql.com
sergefp@mysql.com sergefp@mysql.com
sinisa@rhols221.adsl.netsonic.fi sinisa@rhols221.adsl.netsonic.fi
stewart@mysql.com
tfr@beta.frontier86.ee tfr@beta.frontier86.ee
tfr@indrek.tfr.cafe.ee tfr@indrek.tfr.cafe.ee
tfr@sarvik.tfr.cafe.ee tfr@sarvik.tfr.cafe.ee
......
...@@ -1690,6 +1690,9 @@ ndb_mgm_alloc_nodeid(NdbMgmHandle handle, unsigned int version, int nodetype) ...@@ -1690,6 +1690,9 @@ ndb_mgm_alloc_nodeid(NdbMgmHandle handle, unsigned int version, int nodetype)
{ {
CHECK_HANDLE(handle, 0); CHECK_HANDLE(handle, 0);
CHECK_CONNECTED(handle, 0); CHECK_CONNECTED(handle, 0);
union { long l; char c[sizeof(long)]; } endian_check;
endian_check.l = 1;
int nodeid= handle->cfg._ownNodeId; int nodeid= handle->cfg._ownNodeId;
...@@ -1700,6 +1703,7 @@ ndb_mgm_alloc_nodeid(NdbMgmHandle handle, unsigned int version, int nodetype) ...@@ -1700,6 +1703,7 @@ ndb_mgm_alloc_nodeid(NdbMgmHandle handle, unsigned int version, int nodetype)
args.put("user", "mysqld"); args.put("user", "mysqld");
args.put("password", "mysqld"); args.put("password", "mysqld");
args.put("public key", "a public key"); args.put("public key", "a public key");
args.put("endian", (endian_check.c[sizeof(long)-1])?"big":"little");
const ParserRow<ParserDummy> reply[]= { const ParserRow<ParserDummy> reply[]= {
MGM_CMD("get nodeid reply", NULL, ""), MGM_CMD("get nodeid reply", NULL, ""),
......
...@@ -132,6 +132,7 @@ ParserRow<MgmApiSession> commands[] = { ...@@ -132,6 +132,7 @@ ParserRow<MgmApiSession> commands[] = {
MGM_ARG("user", String, Mandatory, "Password"), MGM_ARG("user", String, Mandatory, "Password"),
MGM_ARG("password", String, Mandatory, "Password"), MGM_ARG("password", String, Mandatory, "Password"),
MGM_ARG("public key", String, Mandatory, "Public key"), MGM_ARG("public key", String, Mandatory, "Public key"),
MGM_ARG("endian", String, Optional, "Endianness"),
MGM_CMD("get version", &MgmApiSession::getVersion, ""), MGM_CMD("get version", &MgmApiSession::getVersion, ""),
...@@ -386,6 +387,8 @@ MgmApiSession::get_nodeid(Parser_t::Context &, ...@@ -386,6 +387,8 @@ MgmApiSession::get_nodeid(Parser_t::Context &,
const char * user; const char * user;
const char * password; const char * password;
const char * public_key; const char * public_key;
const char * endian;
union { long l; char c[sizeof(long)]; } endian_check;
args.get("version", &version); args.get("version", &version);
args.get("nodetype", &nodetype); args.get("nodetype", &nodetype);
...@@ -394,7 +397,17 @@ MgmApiSession::get_nodeid(Parser_t::Context &, ...@@ -394,7 +397,17 @@ MgmApiSession::get_nodeid(Parser_t::Context &,
args.get("user", &user); args.get("user", &user);
args.get("password", &password); args.get("password", &password);
args.get("public key", &public_key); args.get("public key", &public_key);
args.get("endian", &endian);
endian_check.l = 1;
if(endian
&& strcmp(endian,(endian_check.c[sizeof(long)-1])?"big":"little")!=0) {
m_output->println(cmd);
m_output->println("result: Endianness of nodes does not match.");
m_output->println("");
return;
}
bool compatible; bool compatible;
switch (nodetype) { switch (nodetype) {
case NODE_TYPE_MGM: case NODE_TYPE_MGM:
......
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