1
0
mirror of https://github.com/MariaDB/server.git synced 2025-11-15 09:02:33 +03:00

replaced some "localhost" checks with try bind

removed some #id 0 code


ndb/src/common/mgmcommon/ConfigRetriever.cpp:
  replaced some "localhost" checks with try bind
ndb/src/mgmsrv/MgmtSrvr.cpp:
  removed some #id 0 code
This commit is contained in:
unknown
2004-09-17 12:16:34 +00:00
parent e44bcce123
commit dbbe2e1875
2 changed files with 8 additions and 98 deletions

View File

@@ -18,6 +18,7 @@
#include <ndb_version.h>
#include <ConfigRetriever.hpp>
#include <SocketServer.hpp>
#include "LocalConfig.hpp"
#include <NdbSleep.h>
@@ -272,43 +273,15 @@ ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf, Uint32
NdbConfig_SetPath(datadir);
}
char localhost[MAXHOSTNAMELEN];
if(NdbHost_GetHostName(localhost) != 0){
snprintf(buf, 255, "Unable to get own hostname");
if (hostname && hostname[0] != 0 &&
!SocketServer::tryBind(0,hostname)) {
snprintf(buf, 255, "Config hostname(%s) don't match a local interface,"
" tried to bind, error = %d - %s",
hostname, errno, strerror(errno));
setError(CR_ERROR, buf);
return false;
}
do {
if(strlen(hostname) == 0)
break;
if(strcasecmp(hostname, localhost) == 0)
break;
if(strcasecmp(hostname, "localhost") == 0)
break;
struct in_addr local, config;
bool b1 = false, b2 = false, b3 = false;
b1 = Ndb_getInAddr(&local, localhost) == 0;
b2 = Ndb_getInAddr(&config, hostname) == 0;
b3 = memcmp(&local, &config, sizeof(local)) == 0;
if(b1 && b2 && b3)
break;
b1 = Ndb_getInAddr(&local, "localhost") == 0;
b3 = memcmp(&local, &config, sizeof(local)) == 0;
if(b1 && b2 && b3)
break;
snprintf(buf, 255, "Local hostname(%s) and config hostname(%s) dont match",
localhost, hostname);
setError(CR_ERROR, buf);
return false;
} while(false);
unsigned int _type;
if(ndb_mgm_get_int_parameter(it, CFG_TYPE_OF_SECTION, &_type)){
snprintf(buf, 255, "Unable to get type of node(%d) from config",