Added flexibility for connecting and retrieving config from mgmtsrvr

parent 1d343db6
...@@ -2324,25 +2324,38 @@ MgmtSrvr::getFreeNodeId(NodeId * nodeId, enum ndb_mgm_node_type type, ...@@ -2324,25 +2324,38 @@ MgmtSrvr::getFreeNodeId(NodeId * nodeId, enum ndb_mgm_node_type type,
const char *config_hostname = 0; const char *config_hostname = 0;
if(iter.get(CFG_NODE_HOST, &config_hostname)) abort(); if(iter.get(CFG_NODE_HOST, &config_hostname)) abort();
// getsockname(int s, struct sockaddr *name, socklen_t *namelen); if (config_hostname && config_hostname[0] != 0 && client_addr) {
// check hostname compatability
if (config_hostname && config_hostname[0] != 0 && client_addr) { struct in_addr config_addr;
// check hostname compatability const void *tmp= &(((sockaddr_in*)client_addr)->sin_addr);
struct in_addr config_addr; if(Ndb_getInAddr(&config_addr, config_hostname) != 0
if(Ndb_getInAddr(&config_addr, config_hostname) != 0 || memcmp(&config_addr, tmp, sizeof(config_addr)) != 0) {
|| memcmp(&config_addr, &(((sockaddr_in*)client_addr)->sin_addr), struct in_addr tmp_addr;
sizeof(config_addr)) != 0) { if(Ndb_getInAddr(&tmp_addr, "localhost") != 0
|| memcmp(&tmp_addr, tmp, sizeof(config_addr)) != 0) {
// not localhost
#if 0 #if 0
ndbout << "MgmtSrvr::getFreeNodeId compare failed for \"" << config_hostname ndbout << "MgmtSrvr::getFreeNodeId compare failed for \"" << config_hostname
<< "\" id=" << tmp << endl; << "\" id=" << tmp << endl;
#endif #endif
continue; continue;
} }
// connecting through localhost
// check if config_hostname match hostname
char my_hostname[256];
if (gethostname(my_hostname, sizeof(my_hostname)) != 0)
continue;
if(Ndb_getInAddr(&tmp_addr, my_hostname) != 0
|| memcmp(&tmp_addr, &config_addr, sizeof(config_addr)) != 0) {
// no match
continue;
}
}
} }
*nodeId= tmp; *nodeId= tmp;
#if 0 #if 0
ndbout << "MgmtSrvr::getFreeNodeId found type=" << type ndbout << "MgmtSrvr::getFreeNodeId found type=" << type
<< " *nodeid=" << *nodeId << endl; << " *nodeid=" << *nodeId << endl;
#endif #endif
return true; return true;
} }
......
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