Commit 85313326 authored by unknown's avatar unknown

Merge mysql.com:/home/stewart/Documents/MySQL/5.0/ndb

into mysql.com:/home/stewart/Documents/MySQL/5.0/ndb-dynamic-ports-impl3


ndb/src/common/transporter/TransporterRegistry.cpp:
  Auto merged
ndb/src/mgmsrv/ConfigInfo.cpp:
  Auto merged
ndb/src/mgmsrv/MgmtSrvr.cpp:
  Auto merged
ndb/src/mgmsrv/main.cpp:
  Auto merged
parents 6926e703 d362d094
......@@ -83,7 +83,7 @@ public:
* bind & listen
* Returns false if no success
*/
bool setup(Service *, unsigned short port, const char * pinterface = 0);
bool setup(Service *, unsigned short *port, const char * pinterface = 0);
/**
* start/stop the server
......
......@@ -1202,13 +1202,16 @@ TransporterRegistry::start_clients_thread()
&mgm_reply);
DBUG_PRINT("info",("Got dynamic port %u for %d -> %d (ret: %d)",
server_port,t->getRemoteNodeId(),
t->getLocalNodeId()));
t->getLocalNodeId(),res));
if(res>=0)
t->set_r_port(server_port);
else
ndbout_c("Failed to get dynamic port to connect to.");
}
if(t->get_r_port()>0)
t->connect_client();
else
NdbSleep_MilliSleep(400);
}
break;
case DISCONNECTING:
......@@ -1264,7 +1267,7 @@ TransporterRegistry::add_transporter_interface(NodeId remoteNodeId,
for (unsigned i= 0; i < m_transporter_interface.size(); i++)
{
Transporter_interface &tmp= m_transporter_interface[i];
if (port != tmp.m_service_port)
if (port != tmp.m_service_port || tmp.m_service_port==0)
continue;
if (interf != 0 && tmp.m_interface != 0 &&
strcmp(interf, tmp.m_interface) == 0)
......@@ -1297,14 +1300,11 @@ TransporterRegistry::start_service(SocketServer& socket_server)
for (unsigned i= 0; i < m_transporter_interface.size(); i++)
{
Transporter_interface &t= m_transporter_interface[i];
if (t.m_service_port == 0)
{
continue;
}
TransporterService *transporter_service =
new TransporterService(new SocketAuthSimple("ndbd", "ndbd passwd"));
if(!socket_server.setup(transporter_service,
t.m_service_port, t.m_interface))
&t.m_service_port, t.m_interface))
{
ndbout_c("Unable to setup transporter service port: %s:%d!\n"
"Please check if the port is already used,\n"
......
......@@ -82,15 +82,15 @@ SocketServer::tryBind(unsigned short port, const char * intface) {
bool
SocketServer::setup(SocketServer::Service * service,
unsigned short port,
unsigned short * port,
const char * intface){
DBUG_ENTER("SocketServer::setup");
DBUG_PRINT("enter",("interface=%s, port=%d", intface, port));
DBUG_PRINT("enter",("interface=%s, port=%u", intface, *port));
struct sockaddr_in servaddr;
memset(&servaddr, 0, sizeof(servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
servaddr.sin_port = htons(port);
servaddr.sin_port = htons(*port);
if(intface != 0){
if(Ndb_getInAddr(&servaddr.sin_addr, intface))
......@@ -119,7 +119,9 @@ SocketServer::setup(SocketServer::Service * service,
NDB_CLOSE_SOCKET(sock);
DBUG_RETURN(false);
}
socklen_t sock_len = sizeof(servaddr);
getsockname(sock,(struct sockaddr*)&servaddr,&sock_len);
DBUG_PRINT("info",("bound to %u",ntohs(servaddr.sin_port)));
if (listen(sock, m_maxSessions) == -1){
DBUG_PRINT("error",("listen() - %d - %s",
errno, strerror(errno)));
......@@ -131,6 +133,9 @@ SocketServer::setup(SocketServer::Service * service,
i.m_socket = sock;
i.m_service = service;
m_services.push_back(i);
*port = ntohs(servaddr.sin_port);
DBUG_RETURN(true);
}
......
......@@ -29,7 +29,7 @@
#include "common.hpp"
static const char *work_dir = CPCD_DEFAULT_WORK_DIR;
static int port;
static short unsigned int port;
static int use_syslog;
static const char *logfile = NULL;
static const char *config_file = CPCD_DEFAULT_CONFIG_FILE;
......@@ -139,7 +139,7 @@ int main(int argc, char** argv){
SocketServer * ss = new SocketServer();
CPCDAPIService * serv = new CPCDAPIService(cpcd);
if(!ss->setup(serv, port)){
if(!ss->setup(serv, &port)){
logger.critical("Cannot setup server: %s", strerror(errno));
sleep(1);
delete ss;
......
......@@ -3116,37 +3116,6 @@ fixPortNumber(InitConfigFileParser::Context & ctx, const char * data){
Uint32 port= 0;
if (!node->get("ServerPort", &port) &&
!ctx.m_userProperties.get("ServerPort_", id1, &port)) {
Uint32 adder= 0;
{
BaseString server_port_adder(hostname);
server_port_adder.append("_ServerPortAdder");
ctx.m_userProperties.get(server_port_adder.c_str(), &adder);
ctx.m_userProperties.put(server_port_adder.c_str(), adder+1, true);
}
Uint32 base= 0;
if (!ctx.m_userProperties.get("ServerPortBase", &base)){
if(!(ctx.m_userDefaults &&
ctx.m_userDefaults->get("PortNumber", &base)) &&
!ctx.m_systemDefaults->get("PortNumber", &base)) {
base= strtoll(NDB_TCP_BASE_PORT,0,0);
// ctx.reportError("Cannot retrieve base port number");
// return false;
}
ctx.m_userProperties.put("ServerPortBase", base);
}
port= base + adder;
ctx.m_userProperties.put("ServerPort_", id1, port);
}
if(ctx.m_currentSection->contains("PortNumber")) {
ndbout << "PortNumber should no longer be specificied "
<< "per connection, please remove from config. "
<< "Will be changed to " << port << endl;
ctx.m_currentSection->put("PortNumber", port, true);
}
else
{
ctx.m_currentSection->put("PortNumber", port);
}
DBUG_PRINT("info", ("connection %d-%d port %d host %s",
......
......@@ -617,6 +617,26 @@ MgmtSrvr::start(BaseString &error_string)
return false;
}
TransporterRegistry *reg = theFacade->get_registry();
for(unsigned int i=0;i<reg->m_transporter_interface.size();i++) {
BaseString msg;
DBUG_PRINT("info",("Setting dynamic port %d->%d : %u",
reg->get_localNodeId(),
reg->m_transporter_interface[i].m_remote_nodeId,
reg->m_transporter_interface[i].m_service_port
)
);
int res = setConnectionDbParameter((int)reg->get_localNodeId(),
(int)reg->m_transporter_interface[i]
.m_remote_nodeId,
(int)CFG_CONNECTION_SERVER_PORT,
(int)reg->m_transporter_interface[i]
.m_service_port,
msg);
DBUG_PRINT("info",("Set result: %d: %s",res,msg.c_str()));
}
_ownReference = numberToRef(_blockNumber, _ownNodeId);
startEventLog();
......@@ -2793,17 +2813,18 @@ MgmtSrvr::setConnectionDbParameter(int node1,
Uint32 n1,n2;
iter.get(CFG_CONNECTION_NODE_1, &n1);
iter.get(CFG_CONNECTION_NODE_2, &n2);
if(n1 == (unsigned)node1 && n2 == (unsigned)node2)
if((n1 == (unsigned)node1 && n2 == (unsigned)node2)
|| (n1 == (unsigned)node2 && n2 == (unsigned)node1))
break;
}
if(!iter.valid()) {
msg.assign("Unable to find connection between nodes");
return -1;
DBUG_RETURN(-2);
}
if(iter.get(param, &current_value) < 0) {
msg.assign("Unable to get current value of parameter");
return -1;
DBUG_RETURN(-3);
}
ConfigValues::Iterator i2(_config->m_configValues->m_config,
......@@ -2811,16 +2832,16 @@ MgmtSrvr::setConnectionDbParameter(int node1,
if(i2.set(param, (unsigned)value) < 0) {
msg.assign("Unable to set new value of parameter");
return -1;
DBUG_RETURN(-4);
}
if(iter.get(param, &new_value) < 0) {
msg.assign("Unable to get parameter after setting it.");
return -1;
DBUG_RETURN(-5);
}
msg.assfmt("%u -> %u",current_value,new_value);
return 1;
DBUG_RETURN(1);
}
......
......@@ -67,7 +67,7 @@ struct MgmGlobals {
NodeId localNodeId;
bool use_specific_ip;
char * interface_name;
int port;
short unsigned int port;
/** The Mgmt Server */
MgmtSrvr * mgmObject;
......@@ -236,7 +236,7 @@ int main(int argc, char** argv)
glob.interface_name = 0;
}
if(!glob.socketServer->setup(mapi, glob.port, glob.interface_name)){
if(!glob.socketServer->setup(mapi, &glob.port, glob.interface_name)){
ndbout_c("Unable to setup management port: %d!\n"
"Please check if the port is already used,\n"
"(perhaps a ndb_mgmd is already running),\n"
......
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