Commit 1df41ff5 authored by unknown's avatar unknown

Transporter holds a signed port number so the check for a dynamic port in

connect_client thread will work more than just first-time.


ndb/src/common/transporter/Transporter.cpp:
  m_r_port is now m_s_port a SIGNED port. <0 is dynamic
ndb/src/common/transporter/Transporter.hpp:
  m_r_port is now m_s_port, a SIGNED port number (<0 is dynamic).
  
  We give the socket client a positive port though.
ndb/src/common/transporter/TransporterRegistry.cpp:
  Transporter now holds SIGNED port number (<0 dynamic)
parent 6bd9c85a
......@@ -31,14 +31,14 @@ Transporter::Transporter(TransporterRegistry &t_reg,
TransporterType _type,
const char *lHostName,
const char *rHostName,
int r_port,
int s_port,
bool _isMgmConnection,
NodeId lNodeId,
NodeId rNodeId,
NodeId serverNodeId,
int _byteorder,
bool _compression, bool _checksum, bool _signalId)
: m_r_port(r_port), remoteNodeId(rNodeId), localNodeId(lNodeId),
: m_s_port(s_port), remoteNodeId(rNodeId), localNodeId(lNodeId),
isServer(lNodeId==serverNodeId), isMgmConnection(_isMgmConnection),
m_packer(_signalId, _checksum),
m_type(_type),
......@@ -63,10 +63,10 @@ Transporter::Transporter(TransporterRegistry &t_reg,
if (strlen(lHostName) > 0)
Ndb_getInAddr(&localHostAddress, lHostName);
DBUG_PRINT("info",("rId=%d lId=%d isServer=%d rHost=%s lHost=%s r_port=%d",
DBUG_PRINT("info",("rId=%d lId=%d isServer=%d rHost=%s lHost=%s s_port=%d",
remoteNodeId, localNodeId, isServer,
remoteHostName, localHostName,
r_port));
s_port));
byteOrder = _byteorder;
compressionUsed = _compression;
......@@ -76,10 +76,13 @@ Transporter::Transporter(TransporterRegistry &t_reg,
m_connected = false;
m_timeOutMillis = 1000;
if(s_port<0)
s_port= -s_port; // was dynamic
if (isServer)
m_socket_client= 0;
else
m_socket_client= new SocketClient(remoteHostName, r_port,
m_socket_client= new SocketClient(remoteHostName, s_port,
new SocketAuthSimple("ndbd",
"ndbd passwd"));
DBUG_VOID_RETURN;
......@@ -126,7 +129,7 @@ Transporter::connect_client() {
DBUG_ENTER("Transporter::connect_client");
DBUG_PRINT("info",("port %d isMgmConnection=%d",m_r_port,isMgmConnection));
DBUG_PRINT("info",("port %d isMgmConnection=%d",m_s_port,isMgmConnection));
SocketOutputStream s_output(sockfd);
SocketInputStream s_input(sockfd);
......
......@@ -70,15 +70,17 @@ public:
NodeId getLocalNodeId() const;
/**
* Get r_port we're connecting to
* Get port we're connecting to (signed)
*/
unsigned int get_r_port() { return m_r_port; };
int get_s_port() { return m_s_port; };
/**
* Set r_port to connect to
* Set port to connect to (signed)
*/
void set_r_port(unsigned int port) {
m_r_port = port;
void set_s_port(int port) {
m_s_port = port;
if(port<0)
port= -port;
if(m_socket_client)
m_socket_client->set_port(port);
};
......@@ -88,7 +90,7 @@ protected:
TransporterType,
const char *lHostName,
const char *rHostName,
int r_port,
int s_port,
bool isMgmConnection,
NodeId lNodeId,
NodeId rNodeId,
......@@ -118,7 +120,7 @@ protected:
struct in_addr remoteHostAddress;
struct in_addr localHostAddress;
unsigned int m_r_port;
int m_s_port;
const NodeId remoteNodeId;
const NodeId localNodeId;
......
......@@ -1211,7 +1211,7 @@ TransporterRegistry::start_clients_thread()
switch(performStates[nodeId]){
case CONNECTING:
if(!t->isConnected() && !t->isServer) {
if(t->get_r_port() <= 0) { // Port is dynamic
if(t->get_s_port() <= 0) { // Port is dynamic
int server_port= 0;
struct ndb_mgm_reply mgm_reply;
int res;
......@@ -1222,27 +1222,24 @@ TransporterRegistry::start_clients_thread()
CFG_CONNECTION_SERVER_PORT,
&server_port,
&mgm_reply);
DBUG_PRINT("info",("Got %s port %u for %d -> %d (ret: %d)",
(server_port<=0)?"dynamic":"static",
DBUG_PRINT("info",("Got dynamic port %d for %d -> %d (ret: %d)",
server_port,t->getRemoteNodeId(),
t->getLocalNodeId(),res));
if(server_port<0)
server_port = -server_port; // was a dynamic port
if(res>=0)
t->set_r_port(server_port);
if(res>=0 && server_port)
t->set_s_port(server_port);
else
ndbout_c("Failed to get dynamic port to connect to: %d", res);
}
if (theTransporterTypes[nodeId] != tt_TCP_TRANSPORTER
|| t->get_r_port() > 0) {
|| t->get_s_port() > 0) {
int result = t->connect_client();
if (result<0)
ndbout_c("Error while trying to make connection (Node %u to"
" %u via port %u) error: %d. Retrying...",
t->getRemoteNodeId(),
t->getLocalNodeId(),
t->get_r_port());
t->get_s_port());
} else
NdbSleep_MilliSleep(400); // wait before retrying
}
......
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