Below is the list of changes that have just been committed into a local
5.1 repository of jonas. When jonas does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-08-30 11:29:29+02:00, jonas@stripped +3 -0
ndb - bug#27923
add --bind-address to ndb_mgmd
storage/ndb/src/mgmsrv/MgmtSrvr.cpp@stripped, 2007-08-30 11:29:26+02:00, jonas@stripped +4 -4
add own bind address
storage/ndb/src/mgmsrv/MgmtSrvr.hpp@stripped, 2007-08-30 11:29:26+02:00, jonas@stripped +2 -2
add own bind address
storage/ndb/src/mgmsrv/main.cpp@stripped, 2007-08-30 11:29:26+02:00, jonas@stripped +18 -21
add own bind address
diff -Nrup a/storage/ndb/src/mgmsrv/MgmtSrvr.cpp b/storage/ndb/src/mgmsrv/MgmtSrvr.cpp
--- a/storage/ndb/src/mgmsrv/MgmtSrvr.cpp 2007-06-14 12:53:20 +02:00
+++ b/storage/ndb/src/mgmsrv/MgmtSrvr.cpp 2007-08-30 11:29:26 +02:00
@@ -517,7 +517,7 @@ MgmtSrvr::check_start()
}
bool
-MgmtSrvr::start(BaseString &error_string)
+MgmtSrvr::start(BaseString &error_string, const char * bindaddress)
{
int mgm_connect_result;
@@ -557,7 +557,7 @@ MgmtSrvr::start(BaseString &error_string
DBUG_RETURN(false);
}
- if((mgm_connect_result= connect_to_self()) < 0)
+ if((mgm_connect_result= connect_to_self(bindaddress)) < 0)
{
ndbout_c("Unable to connect to our own ndb_mgmd (Error %d)",
mgm_connect_result);
@@ -2985,12 +2985,12 @@ void MgmtSrvr::transporter_connect(NDB_S
}
}
-int MgmtSrvr::connect_to_self(void)
+int MgmtSrvr::connect_to_self(const char * bindaddress)
{
int r= 0;
m_local_mgm_handle= ndb_mgm_create_handle();
snprintf(m_local_mgm_connect_string,sizeof(m_local_mgm_connect_string),
- "localhost:%u",getPort());
+ "%s:%u", bindaddress ? bindaddress : "localhost", getPort());
ndb_mgm_set_connectstring(m_local_mgm_handle, m_local_mgm_connect_string);
if((r= ndb_mgm_connect(m_local_mgm_handle, 0, 0, 0)) < 0)
diff -Nrup a/storage/ndb/src/mgmsrv/MgmtSrvr.hpp b/storage/ndb/src/mgmsrv/MgmtSrvr.hpp
--- a/storage/ndb/src/mgmsrv/MgmtSrvr.hpp 2007-06-14 12:53:20 +02:00
+++ b/storage/ndb/src/mgmsrv/MgmtSrvr.hpp 2007-08-30 11:29:26 +02:00
@@ -168,7 +168,7 @@ public:
* @return true if succeeded, otherwise false
*/
bool check_start(); // may be run before start to check that some things are ok
- bool start(BaseString &error_string);
+ bool start(BaseString &error_string, const char * bindaddress = 0);
~MgmtSrvr();
@@ -442,7 +442,7 @@ public:
int getConnectionDbParameter(int node1, int node2, int param,
int *value, BaseString& msg);
- int connect_to_self(void);
+ int connect_to_self(const char* bindaddress = 0);
void transporter_connect(NDB_SOCKET_TYPE sockfd);
diff -Nrup a/storage/ndb/src/mgmsrv/main.cpp b/storage/ndb/src/mgmsrv/main.cpp
--- a/storage/ndb/src/mgmsrv/main.cpp 2007-05-10 11:59:33 +02:00
+++ b/storage/ndb/src/mgmsrv/main.cpp 2007-08-30 11:29:26 +02:00
@@ -99,6 +99,7 @@ static int opt_non_interactive;
static int opt_interactive;
static const char * opt_config_filename= 0;
static int opt_mycnf = 0;
+static const char* _bind_address = 0;
struct MgmGlobals {
MgmGlobals();
@@ -106,8 +107,6 @@ struct MgmGlobals {
/** Stuff found in environment or in local config */
NodeId localNodeId;
- bool use_specific_ip;
- char * interface_name;
short unsigned int port;
/** The Mgmt Server */
@@ -166,6 +165,10 @@ static struct my_option my_long_options[
"Read cluster config from my.cnf",
(uchar**) &opt_mycnf, (uchar**) &opt_mycnf, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
+ { "bind-address", 256,
+ "Local bind address",
+ (uchar**) &_bind_address, (uchar**) &_bind_address, 0,
+ GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
@@ -249,12 +252,9 @@ start:
if (glob->port == 0)
goto error_end;
- glob->interface_name = 0;
- glob->use_specific_ip = false;
-
- if(!glob->use_specific_ip){
+ {
int count= 5; // no of retries for tryBind
- while(!glob->socketServer->tryBind(glob->port, glob->interface_name)){
+ while(!glob->socketServer->tryBind(glob->port, _bind_address)){
if (--count > 0) {
NdbSleep_MilliSleep(1000);
continue;
@@ -263,20 +263,18 @@ start:
"Please check if the port is already used,\n"
"(perhaps a ndb_mgmd is already running),\n"
"and if you are executing on the correct computer",
- (glob->interface_name ? glob->interface_name : "*"), glob->port);
+ (_bind_address ? _bind_address : "*"), glob->port);
goto error_end;
}
- free(glob->interface_name);
- glob->interface_name = 0;
}
- if(!glob->socketServer->setup(mapi, &glob->port, glob->interface_name))
+ if(!glob->socketServer->setup(mapi, &glob->port, _bind_address))
{
- ndbout_c("Unable to setup management port: %d!\n"
+ ndbout_c("Unable to setup management port: %s:%d!\n"
"Please check if the port is already used,\n"
"(perhaps a ndb_mgmd is already running),\n"
"and if you are executing on the correct computer",
- glob->port);
+ (_bind_address ? _bind_address : "*"), glob->port);
delete mapi;
goto error_end;
}
@@ -304,7 +302,7 @@ start:
#endif
{
BaseString error_string;
- if(!glob->mgmObject->start(error_string)){
+ if(!glob->mgmObject->start(error_string, _bind_address)){
ndbout_c("Unable to start management server.");
ndbout_c("Probably caused by illegal initial configuration file.");
ndbout_c(error_string.c_str());
@@ -321,8 +319,10 @@ start:
ndbout_c(msg);
g_eventLogger.info(msg);
- BaseString::snprintf(msg, 256, "Id: %d, Command port: %d",
- glob->localNodeId, glob->port);
+ BaseString::snprintf(msg, 256, "Id: %d, Command port: %s:%d",
+ glob->localNodeId,
+ _bind_address ? _bind_address : "*",
+ glob->port);
ndbout_c(msg);
g_eventLogger.info(msg);
@@ -332,8 +332,8 @@ start:
if(opt_interactive) {
BaseString con_str;
- if(glob->interface_name)
- con_str.appfmt("host=%s:%d", glob->interface_name, glob->port);
+ if(_bind_address)
+ con_str.appfmt("host=%s:%d", _bind_address, glob->port);
else
con_str.appfmt("localhost:%d", glob->port);
Ndb_mgmclient com(con_str.c_str(), 1);
@@ -367,7 +367,6 @@ start:
MgmGlobals::MgmGlobals(){
// Default values
port = 0;
- interface_name = 0;
socketServer = 0;
mgmObject = 0;
}
@@ -377,6 +376,4 @@ MgmGlobals::~MgmGlobals(){
delete socketServer;
if (mgmObject)
delete mgmObject;
- if (interface_name)
- free(interface_name);
}
| Thread |
|---|
| • bk commit into 5.1 tree (jonas:1.2573) BUG#27923 | jonas | 30 Aug |