diff options
author | unknown <tomas@poseidon.ndb.mysql.com> | 2004-06-30 14:56:16 +0000 |
---|---|---|
committer | unknown <tomas@poseidon.ndb.mysql.com> | 2004-06-30 14:56:16 +0000 |
commit | 1ed75f56798fcd13137c92809fea04b949535de4 (patch) | |
tree | 1ec6561c168f76304ee807be49a27216ae621e09 /ndb | |
parent | 426b2ac2b4b7e9ed8cd7f1a191267272973052a3 (diff) | |
download | mariadb-git-1ed75f56798fcd13137c92809fea04b949535de4.tar.gz |
Added flexibility for connecting and retrieving config from mgmtsrvr
Diffstat (limited to 'ndb')
-rw-r--r-- | ndb/src/mgmsrv/MgmtSrvr.cpp | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/ndb/src/mgmsrv/MgmtSrvr.cpp b/ndb/src/mgmsrv/MgmtSrvr.cpp index 1a5a4d1a877..33ac4ddcf99 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.cpp +++ b/ndb/src/mgmsrv/MgmtSrvr.cpp @@ -2324,25 +2324,38 @@ MgmtSrvr::getFreeNodeId(NodeId * nodeId, enum ndb_mgm_node_type type, const char *config_hostname = 0; 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 - struct in_addr config_addr; - if(Ndb_getInAddr(&config_addr, config_hostname) != 0 - || memcmp(&config_addr, &(((sockaddr_in*)client_addr)->sin_addr), - sizeof(config_addr)) != 0) { + if (config_hostname && config_hostname[0] != 0 && client_addr) { + // check hostname compatability + struct in_addr config_addr; + const void *tmp= &(((sockaddr_in*)client_addr)->sin_addr); + if(Ndb_getInAddr(&config_addr, config_hostname) != 0 + || memcmp(&config_addr, tmp, sizeof(config_addr)) != 0) { + struct in_addr tmp_addr; + if(Ndb_getInAddr(&tmp_addr, "localhost") != 0 + || memcmp(&tmp_addr, tmp, sizeof(config_addr)) != 0) { + // not localhost #if 0 - ndbout << "MgmtSrvr::getFreeNodeId compare failed for \"" << config_hostname - << "\" id=" << tmp << endl; + ndbout << "MgmtSrvr::getFreeNodeId compare failed for \"" << config_hostname + << "\" id=" << tmp << endl; #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; #if 0 - ndbout << "MgmtSrvr::getFreeNodeId found type=" << type - << " *nodeid=" << *nodeId << endl; + ndbout << "MgmtSrvr::getFreeNodeId found type=" << type + << " *nodeid=" << *nodeId << endl; #endif return true; } |