Commit f2e98ab5 authored by unknown's avatar unknown

Distinguish between "real" ports and those that can be negative (dynamic).

(Suggested by Tomas Ulin as part of review for WL2278)


ndb/include/transporter/TransporterRegistry.hpp:
  Differentiate signed port numbers from unsigned ones
ndb/src/common/mgmcommon/IPCConfig.cpp:
  Explain the sign of server_port
ndb/src/common/transporter/TransporterRegistry.cpp:
  Use s_port to indicate a signed port number.
ndb/src/kernel/main.cpp:
  use m_s_service_port to indicate signed port number
ndb/src/mgmsrv/MgmtSrvr.cpp:
  differentiate between signed and unsigned port numbers
ndb/src/ndbapi/ndb_cluster_connection.cpp:
  use m_s_service_port to indicate signed port number
parent 48f05d2f
...@@ -232,12 +232,12 @@ public: ...@@ -232,12 +232,12 @@ public:
class Transporter_interface { class Transporter_interface {
public: public:
NodeId m_remote_nodeId; NodeId m_remote_nodeId;
int m_service_port; int m_s_service_port; // signed port number
const char *m_interface; const char *m_interface;
}; };
Vector<Transporter_interface> m_transporter_interface; Vector<Transporter_interface> m_transporter_interface;
void add_transporter_interface(NodeId remoteNodeId, const char *interf, void add_transporter_interface(NodeId remoteNodeId, const char *interf,
int port); int s_port); // signed port. <0 is dynamic
Transporter* get_transporter(NodeId nodeId); Transporter* get_transporter(NodeId nodeId);
NodeId get_localNodeId() { return localNodeId; }; NodeId get_localNodeId() { return localNodeId; };
......
...@@ -371,8 +371,18 @@ IPCConfig::configureTransporters(Uint32 nodeId, ...@@ -371,8 +371,18 @@ IPCConfig::configureTransporters(Uint32 nodeId,
} }
DBUG_PRINT("info", ("Transporter between this node %d and node %d using port %d, signalId %d, checksum %d", DBUG_PRINT("info", ("Transporter between this node %d and node %d using port %d, signalId %d, checksum %d",
nodeId, remoteNodeId, server_port, sendSignalId, checksum)); nodeId, remoteNodeId, server_port, sendSignalId, checksum));
/*
This may be a dynamic port. It depends on when we're getting
our configuration. If we've been restarted, we'll be getting
a configuration with our old dynamic port in it, hence the number
here is negative (and we try the old port number first).
On a first-run, server_port will be zero (with dynamic ports)
If we're not using dynamic ports, we don't do anything.
*/
if((int)server_port<0) if((int)server_port<0)
server_port= -server_port; // A dynamic port server_port= -server_port;
switch(type){ switch(type){
case CONNECTION_TYPE_SHM:{ case CONNECTION_TYPE_SHM:{
......
...@@ -1267,17 +1267,17 @@ TransporterRegistry::stop_clients() ...@@ -1267,17 +1267,17 @@ TransporterRegistry::stop_clients()
void void
TransporterRegistry::add_transporter_interface(NodeId remoteNodeId, TransporterRegistry::add_transporter_interface(NodeId remoteNodeId,
const char *interf, const char *interf,
int port) int s_port)
{ {
DBUG_ENTER("TransporterRegistry::add_transporter_interface"); DBUG_ENTER("TransporterRegistry::add_transporter_interface");
DBUG_PRINT("enter",("interface=%s, port= %d", interf, port)); DBUG_PRINT("enter",("interface=%s, s_port= %d", interf, s_port));
if (interf && strlen(interf) == 0) if (interf && strlen(interf) == 0)
interf= 0; interf= 0;
for (unsigned i= 0; i < m_transporter_interface.size(); i++) for (unsigned i= 0; i < m_transporter_interface.size(); i++)
{ {
Transporter_interface &tmp= m_transporter_interface[i]; Transporter_interface &tmp= m_transporter_interface[i];
if (port != tmp.m_service_port || tmp.m_service_port==0) if (s_port != tmp.m_s_service_port || tmp.m_s_service_port==0)
continue; continue;
if (interf != 0 && tmp.m_interface != 0 && if (interf != 0 && tmp.m_interface != 0 &&
strcmp(interf, tmp.m_interface) == 0) strcmp(interf, tmp.m_interface) == 0)
...@@ -1291,7 +1291,7 @@ TransporterRegistry::add_transporter_interface(NodeId remoteNodeId, ...@@ -1291,7 +1291,7 @@ TransporterRegistry::add_transporter_interface(NodeId remoteNodeId,
} }
Transporter_interface t; Transporter_interface t;
t.m_remote_nodeId= remoteNodeId; t.m_remote_nodeId= remoteNodeId;
t.m_service_port= port; t.m_s_service_port= s_port;
t.m_interface= interf; t.m_interface= interf;
m_transporter_interface.push_back(t); m_transporter_interface.push_back(t);
DBUG_PRINT("exit",("interface and port added")); DBUG_PRINT("exit",("interface and port added"));
...@@ -1311,9 +1311,9 @@ TransporterRegistry::start_service(SocketServer& socket_server) ...@@ -1311,9 +1311,9 @@ TransporterRegistry::start_service(SocketServer& socket_server)
{ {
Transporter_interface &t= m_transporter_interface[i]; Transporter_interface &t= m_transporter_interface[i];
unsigned short port= t.m_service_port; unsigned short port= (unsigned short)t.m_s_service_port;
if(t.m_service_port<0) if(t.m_s_service_port<0)
port= -t.m_service_port; // is a dynamic port port= -t.m_s_service_port; // is a dynamic port
TransporterService *transporter_service = TransporterService *transporter_service =
new TransporterService(new SocketAuthSimple("ndbd", "ndbd passwd")); new TransporterService(new SocketAuthSimple("ndbd", "ndbd passwd"));
if(!socket_server.setup(transporter_service, if(!socket_server.setup(transporter_service,
...@@ -1321,7 +1321,7 @@ TransporterRegistry::start_service(SocketServer& socket_server) ...@@ -1321,7 +1321,7 @@ TransporterRegistry::start_service(SocketServer& socket_server)
{ {
DBUG_PRINT("info", ("Trying new port")); DBUG_PRINT("info", ("Trying new port"));
port= 0; port= 0;
if(t.m_service_port>0 if(t.m_s_service_port>0
|| !socket_server.setup(transporter_service, || !socket_server.setup(transporter_service,
&port, t.m_interface)) &port, t.m_interface))
{ {
...@@ -1332,13 +1332,13 @@ TransporterRegistry::start_service(SocketServer& socket_server) ...@@ -1332,13 +1332,13 @@ TransporterRegistry::start_service(SocketServer& socket_server)
ndbout_c("Unable to setup transporter service port: %s:%d!\n" ndbout_c("Unable to setup transporter service port: %s:%d!\n"
"Please check if the port is already used,\n" "Please check if the port is already used,\n"
"(perhaps the node is already running)", "(perhaps the node is already running)",
t.m_interface ? t.m_interface : "*", t.m_service_port); t.m_interface ? t.m_interface : "*", t.m_s_service_port);
delete transporter_service; delete transporter_service;
return false; return false;
} }
} }
t.m_service_port= (t.m_service_port<=0)?-port:port; // -`ve if dynamic t.m_s_service_port= (t.m_s_service_port<=0)?-port:port; // -`ve if dynamic
DBUG_PRINT("info", ("t.m_service_port = %d",t.m_service_port)); DBUG_PRINT("info", ("t.m_s_service_port = %d",t.m_s_service_port));
transporter_service->setTransporterRegistry(this); transporter_service->setTransporterRegistry(this);
} }
return true; return true;
......
...@@ -211,7 +211,7 @@ int main(int argc, char** argv) ...@@ -211,7 +211,7 @@ int main(int argc, char** argv)
globalTransporterRegistry.get_localNodeId(), globalTransporterRegistry.get_localNodeId(),
globalTransporterRegistry.m_transporter_interface[i].m_remote_nodeId, globalTransporterRegistry.m_transporter_interface[i].m_remote_nodeId,
CFG_CONNECTION_SERVER_PORT, CFG_CONNECTION_SERVER_PORT,
globalTransporterRegistry.m_transporter_interface[i].m_service_port, globalTransporterRegistry.m_transporter_interface[i].m_s_service_port,
&mgm_reply); &mgm_reply);
......
...@@ -620,18 +620,18 @@ MgmtSrvr::start(BaseString &error_string) ...@@ -620,18 +620,18 @@ MgmtSrvr::start(BaseString &error_string)
TransporterRegistry *reg = theFacade->get_registry(); TransporterRegistry *reg = theFacade->get_registry();
for(unsigned int i=0;i<reg->m_transporter_interface.size();i++) { for(unsigned int i=0;i<reg->m_transporter_interface.size();i++) {
BaseString msg; BaseString msg;
DBUG_PRINT("info",("Setting dynamic port %d->%d : %u", DBUG_PRINT("info",("Setting dynamic port %d->%d : %d",
reg->get_localNodeId(), reg->get_localNodeId(),
reg->m_transporter_interface[i].m_remote_nodeId, reg->m_transporter_interface[i].m_remote_nodeId,
reg->m_transporter_interface[i].m_service_port reg->m_transporter_interface[i].m_s_service_port
) )
); );
int res = setConnectionDbParameter((int)reg->get_localNodeId(), int res = setConnectionDbParameter((int)reg->get_localNodeId(),
(int)reg->m_transporter_interface[i] (int)reg->m_transporter_interface[i]
.m_remote_nodeId, .m_remote_nodeId,
(int)CFG_CONNECTION_SERVER_PORT, (int)CFG_CONNECTION_SERVER_PORT,
(int)reg->m_transporter_interface[i] reg->m_transporter_interface[i]
.m_service_port, .m_s_service_port,
msg); msg);
DBUG_PRINT("info",("Set result: %d: %s",res,msg.c_str())); DBUG_PRINT("info",("Set result: %d: %s",res,msg.c_str()));
} }
......
...@@ -500,7 +500,7 @@ int Ndb_cluster_connection::connect(int no_retries, int retry_delay_in_seconds, ...@@ -500,7 +500,7 @@ int Ndb_cluster_connection::connect(int no_retries, int retry_delay_in_seconds,
CFG_CONNECTION_SERVER_PORT, CFG_CONNECTION_SERVER_PORT,
m_impl.m_transporter_facade->get_registry() m_impl.m_transporter_facade->get_registry()
->m_transporter_interface[i] ->m_transporter_interface[i]
.m_service_port, .m_s_service_port,
&mgm_reply); &mgm_reply);
ndb_mgm_destroy_configuration(props); ndb_mgm_destroy_configuration(props);
......
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