changed ndb dynamic port fetch sligtly to handle "not connected" cases better

parent 3f023ee3
...@@ -1246,13 +1246,13 @@ TransporterRegistry::start_clients_thread() ...@@ -1246,13 +1246,13 @@ TransporterRegistry::start_clients_thread()
if( !connected && t->get_s_port() <= 0) { // Port is dynamic if( !connected && 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= -1;
if(!ndb_mgm_is_connected(m_mgm_handle)) if(!ndb_mgm_is_connected(m_mgm_handle))
if(ndb_mgm_connect(m_mgm_handle, 0, 0, 0)<0) ndb_mgm_connect(m_mgm_handle, 0, 0, 0);
ndbout_c("Failed to reconnect to management server");
else if(ndb_mgm_is_connected(m_mgm_handle))
res= {
int res=
ndb_mgm_get_connection_int_parameter(m_mgm_handle, ndb_mgm_get_connection_int_parameter(m_mgm_handle,
t->getRemoteNodeId(), t->getRemoteNodeId(),
t->getLocalNodeId(), t->getLocalNodeId(),
...@@ -1262,11 +1262,29 @@ TransporterRegistry::start_clients_thread() ...@@ -1262,11 +1262,29 @@ TransporterRegistry::start_clients_thread()
DBUG_PRINT("info",("Got dynamic port %d for %d -> %d (ret: %d)", DBUG_PRINT("info",("Got dynamic port %d for %d -> %d (ret: %d)",
server_port,t->getRemoteNodeId(), server_port,t->getRemoteNodeId(),
t->getLocalNodeId(),res)); t->getLocalNodeId(),res));
if( res >= 0 )
if(res>=0 && server_port) {
/**
* Server_port == 0 just means that that a mgmt server
* has not received a new port yet. Keep the old.
*/
if (server_port)
t->set_s_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);
ndb_mgm_disconnect(m_mgm_handle);
}
}
/** else
* We will not be able to get a new port unless
* the m_mgm_handle is connected. Note that not
* being connected is an ok state, just continue
* until it is able to connect. Continue using the
* old port until we can connect again and get a
* new port.
*/
} }
} }
break; break;
...@@ -1304,7 +1322,7 @@ TransporterRegistry::stop_clients() ...@@ -1304,7 +1322,7 @@ TransporterRegistry::stop_clients()
if (m_start_clients_thread) { if (m_start_clients_thread) {
m_run_start_clients_thread= false; m_run_start_clients_thread= false;
void* status; void* status;
int r= NdbThread_WaitFor(m_start_clients_thread, &status); NdbThread_WaitFor(m_start_clients_thread, &status);
NdbThread_Destroy(&m_start_clients_thread); NdbThread_Destroy(&m_start_clients_thread);
} }
return true; return true;
...@@ -1347,10 +1365,11 @@ TransporterRegistry::add_transporter_interface(NodeId remoteNodeId, ...@@ -1347,10 +1365,11 @@ TransporterRegistry::add_transporter_interface(NodeId remoteNodeId,
bool bool
TransporterRegistry::start_service(SocketServer& socket_server) TransporterRegistry::start_service(SocketServer& socket_server)
{ {
DBUG_ENTER("TransporterRegistry::start_service");
if (m_transporter_interface.size() > 0 && !nodeIdSpecified) if (m_transporter_interface.size() > 0 && !nodeIdSpecified)
{ {
ndbout_c("TransporterRegistry::startReceiving: localNodeId not specified"); ndbout_c("TransporterRegistry::startReceiving: localNodeId not specified");
return false; DBUG_RETURN(false);
} }
for (unsigned i= 0; i < m_transporter_interface.size(); i++) for (unsigned i= 0; i < m_transporter_interface.size(); i++)
...@@ -1380,14 +1399,14 @@ TransporterRegistry::start_service(SocketServer& socket_server) ...@@ -1380,14 +1399,14 @@ TransporterRegistry::start_service(SocketServer& socket_server)
"(perhaps the node is already running)", "(perhaps the node is already running)",
t.m_interface ? t.m_interface : "*", t.m_s_service_port); t.m_interface ? t.m_interface : "*", t.m_s_service_port);
delete transporter_service; delete transporter_service;
return false; DBUG_RETURN(false);
} }
} }
t.m_s_service_port= (t.m_s_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_s_service_port = %d",t.m_s_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; DBUG_RETURN(true);
} }
#ifdef NDB_SHM_TRANSPORTER #ifdef NDB_SHM_TRANSPORTER
......
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