diff --git a/ndb/src/common/transporter/Transporter.cpp b/ndb/src/common/transporter/Transporter.cpp index 86fabc839c7d89398eb1a29425472450fcabe25f..a888d98b8321d88147325822548fb529df71c0f3 100644 --- a/ndb/src/common/transporter/Transporter.cpp +++ b/ndb/src/common/transporter/Transporter.cpp @@ -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); diff --git a/ndb/src/common/transporter/Transporter.hpp b/ndb/src/common/transporter/Transporter.hpp index 736481a3250c81a53947ce9848663ce83fac03f6..5b25afa0d89db6e253ae07775211f46bd16a92e6 100644 --- a/ndb/src/common/transporter/Transporter.hpp +++ b/ndb/src/common/transporter/Transporter.hpp @@ -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; diff --git a/ndb/src/common/transporter/TransporterRegistry.cpp b/ndb/src/common/transporter/TransporterRegistry.cpp index b159c0b213ee2dac08e24c55bfbef30a2844e920..a84a42554febed76440874b129046890c7316509 100644 --- a/ndb/src/common/transporter/TransporterRegistry.cpp +++ b/ndb/src/common/transporter/TransporterRegistry.cpp @@ -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 }