mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 11:01:52 +01:00
Added flexibility for connecting and retrieving config from mgmtsrvr
This commit is contained in:
parent
1d343db665
commit
5e6a1a89ef
1 changed files with 27 additions and 14 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue