summaryrefslogtreecommitdiff
path: root/ndb
diff options
context:
space:
mode:
authorunknown <stewart@mysql.com>2005-01-04 16:12:17 +1100
committerunknown <stewart@mysql.com>2005-01-04 16:12:17 +1100
commit85313326356cc3c859203425a907327ed8bafdcb (patch)
treefb50101a61b339c1458a61b51c8091a4b68eff68 /ndb
parent6926e703851cf5703e701665690ce9f34aa39b0d (diff)
parentd362d09408931f1ee751886763355a5d05b8da70 (diff)
downloadmariadb-git-85313326356cc3c859203425a907327ed8bafdcb.tar.gz
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
Diffstat (limited to 'ndb')
-rw-r--r--ndb/include/util/SocketServer.hpp2
-rw-r--r--ndb/src/common/transporter/TransporterRegistry.cpp16
-rw-r--r--ndb/src/common/util/SocketServer.cpp13
-rw-r--r--ndb/src/cw/cpcd/main.cpp4
-rw-r--r--ndb/src/mgmsrv/ConfigInfo.cpp31
-rw-r--r--ndb/src/mgmsrv/MgmtSrvr.cpp33
-rw-r--r--ndb/src/mgmsrv/main.cpp4
7 files changed, 49 insertions, 54 deletions
diff --git a/ndb/include/util/SocketServer.hpp b/ndb/include/util/SocketServer.hpp
index 9d8af204391..2e1afb74945 100644
--- a/ndb/include/util/SocketServer.hpp
+++ b/ndb/include/util/SocketServer.hpp
@@ -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
diff --git a/ndb/src/common/transporter/TransporterRegistry.cpp b/ndb/src/common/transporter/TransporterRegistry.cpp
index 506d2018afc..22ddc3b71e4 100644
--- a/ndb/src/common/transporter/TransporterRegistry.cpp
+++ b/ndb/src/common/transporter/TransporterRegistry.cpp
@@ -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.");
}
- t->connect_client();
+ 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"
diff --git a/ndb/src/common/util/SocketServer.cpp b/ndb/src/common/util/SocketServer.cpp
index 8bee256684d..d2caf9c920c 100644
--- a/ndb/src/common/util/SocketServer.cpp
+++ b/ndb/src/common/util/SocketServer.cpp
@@ -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);
}
diff --git a/ndb/src/cw/cpcd/main.cpp b/ndb/src/cw/cpcd/main.cpp
index 300b51d7b5a..9132fbb1c94 100644
--- a/ndb/src/cw/cpcd/main.cpp
+++ b/ndb/src/cw/cpcd/main.cpp
@@ -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;
diff --git a/ndb/src/mgmsrv/ConfigInfo.cpp b/ndb/src/mgmsrv/ConfigInfo.cpp
index 800ffe2e361..4a243875bf7 100644
--- a/ndb/src/mgmsrv/ConfigInfo.cpp
+++ b/ndb/src/mgmsrv/ConfigInfo.cpp
@@ -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",
diff --git a/ndb/src/mgmsrv/MgmtSrvr.cpp b/ndb/src/mgmsrv/MgmtSrvr.cpp
index 63e9c5c68c7..d29422c4b65 100644
--- a/ndb/src/mgmsrv/MgmtSrvr.cpp
+++ b/ndb/src/mgmsrv/MgmtSrvr.cpp
@@ -616,6 +616,26 @@ MgmtSrvr::start(BaseString &error_string)
theFacade = 0;
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);
@@ -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);
}
diff --git a/ndb/src/mgmsrv/main.cpp b/ndb/src/mgmsrv/main.cpp
index 4a8b79d3ddc..5c289fc9d1c 100644
--- a/ndb/src/mgmsrv/main.cpp
+++ b/ndb/src/mgmsrv/main.cpp
@@ -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"