Commit 377ffd15 authored by stewart@mysql.com's avatar stewart@mysql.com

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

connect_client thread will work more than just first-time.
parent 196def91
...@@ -31,14 +31,14 @@ Transporter::Transporter(TransporterRegistry &t_reg, ...@@ -31,14 +31,14 @@ Transporter::Transporter(TransporterRegistry &t_reg,
TransporterType _type, TransporterType _type,
const char *lHostName, const char *lHostName,
const char *rHostName, const char *rHostName,
int r_port, int s_port,
bool _isMgmConnection, bool _isMgmConnection,
NodeId lNodeId, NodeId lNodeId,
NodeId rNodeId, NodeId rNodeId,
NodeId serverNodeId, NodeId serverNodeId,
int _byteorder, int _byteorder,
bool _compression, bool _checksum, bool _signalId) 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), isServer(lNodeId==serverNodeId), isMgmConnection(_isMgmConnection),
m_packer(_signalId, _checksum), m_packer(_signalId, _checksum),
m_type(_type), m_type(_type),
...@@ -63,10 +63,10 @@ Transporter::Transporter(TransporterRegistry &t_reg, ...@@ -63,10 +63,10 @@ Transporter::Transporter(TransporterRegistry &t_reg,
if (strlen(lHostName) > 0) if (strlen(lHostName) > 0)
Ndb_getInAddr(&localHostAddress, lHostName); 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, remoteNodeId, localNodeId, isServer,
remoteHostName, localHostName, remoteHostName, localHostName,
r_port)); s_port));
byteOrder = _byteorder; byteOrder = _byteorder;
compressionUsed = _compression; compressionUsed = _compression;
...@@ -76,10 +76,13 @@ Transporter::Transporter(TransporterRegistry &t_reg, ...@@ -76,10 +76,13 @@ Transporter::Transporter(TransporterRegistry &t_reg,
m_connected = false; m_connected = false;
m_timeOutMillis = 1000; m_timeOutMillis = 1000;
if(s_port<0)
s_port= -s_port; // was dynamic
if (isServer) if (isServer)
m_socket_client= 0; m_socket_client= 0;
else else
m_socket_client= new SocketClient(remoteHostName, r_port, m_socket_client= new SocketClient(remoteHostName, s_port,
new SocketAuthSimple("ndbd", new SocketAuthSimple("ndbd",
"ndbd passwd")); "ndbd passwd"));
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
...@@ -126,7 +129,7 @@ Transporter::connect_client() { ...@@ -126,7 +129,7 @@ Transporter::connect_client() {
DBUG_ENTER("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); SocketOutputStream s_output(sockfd);
SocketInputStream s_input(sockfd); SocketInputStream s_input(sockfd);
......
...@@ -70,15 +70,17 @@ public: ...@@ -70,15 +70,17 @@ public:
NodeId getLocalNodeId() const; 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) { void set_s_port(int port) {
m_r_port = port; m_s_port = port;
if(port<0)
port= -port;
if(m_socket_client) if(m_socket_client)
m_socket_client->set_port(port); m_socket_client->set_port(port);
}; };
...@@ -88,7 +90,7 @@ protected: ...@@ -88,7 +90,7 @@ protected:
TransporterType, TransporterType,
const char *lHostName, const char *lHostName,
const char *rHostName, const char *rHostName,
int r_port, int s_port,
bool isMgmConnection, bool isMgmConnection,
NodeId lNodeId, NodeId lNodeId,
NodeId rNodeId, NodeId rNodeId,
...@@ -118,7 +120,7 @@ protected: ...@@ -118,7 +120,7 @@ protected:
struct in_addr remoteHostAddress; struct in_addr remoteHostAddress;
struct in_addr localHostAddress; struct in_addr localHostAddress;
unsigned int m_r_port; int m_s_port;
const NodeId remoteNodeId; const NodeId remoteNodeId;
const NodeId localNodeId; const NodeId localNodeId;
......
...@@ -1211,7 +1211,7 @@ TransporterRegistry::start_clients_thread() ...@@ -1211,7 +1211,7 @@ TransporterRegistry::start_clients_thread()
switch(performStates[nodeId]){ switch(performStates[nodeId]){
case CONNECTING: case CONNECTING:
if(!t->isConnected() && !t->isServer) { 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; int server_port= 0;
struct ndb_mgm_reply mgm_reply; struct ndb_mgm_reply mgm_reply;
int res; int res;
...@@ -1222,27 +1222,24 @@ TransporterRegistry::start_clients_thread() ...@@ -1222,27 +1222,24 @@ TransporterRegistry::start_clients_thread()
CFG_CONNECTION_SERVER_PORT, CFG_CONNECTION_SERVER_PORT,
&server_port, &server_port,
&mgm_reply); &mgm_reply);
DBUG_PRINT("info",("Got %s port %u for %d -> %d (ret: %d)", DBUG_PRINT("info",("Got dynamic port %d for %d -> %d (ret: %d)",
(server_port<=0)?"dynamic":"static",
server_port,t->getRemoteNodeId(), server_port,t->getRemoteNodeId(),
t->getLocalNodeId(),res)); t->getLocalNodeId(),res));
if(server_port<0)
server_port = -server_port; // was a dynamic port
if(res>=0) if(res>=0 && server_port)
t->set_r_port(server_port); t->set_s_port(server_port);
else else
ndbout_c("Failed to get dynamic port to connect to: %d", res); ndbout_c("Failed to get dynamic port to connect to: %d", res);
} }
if (theTransporterTypes[nodeId] != tt_TCP_TRANSPORTER if (theTransporterTypes[nodeId] != tt_TCP_TRANSPORTER
|| t->get_r_port() > 0) { || t->get_s_port() > 0) {
int result = t->connect_client(); int result = t->connect_client();
if (result<0) if (result<0)
ndbout_c("Error while trying to make connection (Node %u to" ndbout_c("Error while trying to make connection (Node %u to"
" %u via port %u) error: %d. Retrying...", " %u via port %u) error: %d. Retrying...",
t->getRemoteNodeId(), t->getRemoteNodeId(),
t->getLocalNodeId(), t->getLocalNodeId(),
t->get_r_port()); t->get_s_port());
} else } else
NdbSleep_MilliSleep(400); // wait before retrying 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