Commit 7fda6861 authored by stewart@mysql.com's avatar stewart@mysql.com

Fixes from Tomas's review of 'use configuration mgm handle as a transporter'.

This should help with the  PURGE STALE SESSIONS problem.
parent e94e9fa6
......@@ -1374,11 +1374,6 @@ TransporterRegistry::start_service(SocketServer& socket_server)
DBUG_RETURN(false);
}
if(!ndb_mgm_is_connected(m_mgm_handle))
ndb_mgm_connect(m_mgm_handle, 0, 0, 0);
if(!ndb_mgm_is_connected(m_mgm_handle))
DBUG_RETURN(false);
for (unsigned i= 0; i < m_transporter_interface.size(); i++)
{
Transporter_interface &t= m_transporter_interface[i];
......@@ -1411,18 +1406,6 @@ TransporterRegistry::start_service(SocketServer& socket_server)
}
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));
if(t.m_s_service_port < 0
&& ndb_mgm_set_connection_int_parameter(m_mgm_handle,
get_localNodeId(),
t.m_remote_nodeId,
CFG_CONNECTION_SERVER_PORT,
t.m_s_service_port,
&mgm_reply) < 0)
{
delete transporter_service;
DBUG_RETURN(false);
}
transporter_service->setTransporterRegistry(this);
}
DBUG_RETURN(true);
......@@ -1609,25 +1592,9 @@ NDB_SOCKET_TYPE TransporterRegistry::connect_ndb_mgmd(SocketClient *sc)
* Set connectstring
*/
{
char c[100];
char *cs= &c[0];
unsigned len= strlen(sc->get_server_name())+20;
if( len > sizeof(c) )
{
/*
* server name is long. malloc enough for it and the port number
*/
cs= (char*)malloc(len*sizeof(char));
if(!cs)
{
ndb_mgm_destroy_handle(&h);
return NDB_INVALID_SOCKET;
}
}
snprintf(cs,len,"%s:%u",sc->get_server_name(),sc->get_port());
ndb_mgm_set_connectstring(h, cs);
if(cs != &c[0])
free(cs);
BaseString cs;
cs.assfmt("%s:%u",sc->get_server_name(),sc->get_port());
ndb_mgm_set_connectstring(h, cs.c_str());
}
if(ndb_mgm_connect(h, 0, 0, 0)<0)
......
......@@ -190,6 +190,13 @@ int main(int argc, char** argv)
exit(-1);
}
// Re-use the mgm handle as a transporter
if(!globalTransporterRegistry.connect_client(
theConfig->get_config_retriever()->get_mgmHandlePtr()))
ERROR_SET(fatal, ERR_INVALID_CONFIG,
"Connection to mgmd terminated before setup was complete",
"StopOnError missing");
if (!globalTransporterRegistry.start_clients()){
ndbout_c("globalTransporterRegistry.start_clients() failed");
exit(-1);
......
......@@ -154,7 +154,6 @@ Configuration::Configuration()
m_config_retriever= 0;
m_clusterConfig= 0;
m_clusterConfigIter= 0;
m_mgmd_host= NULL;
}
Configuration::~Configuration(){
......@@ -167,9 +166,6 @@ Configuration::~Configuration(){
if(_backupPath != NULL)
free(_backupPath);
if(m_mgmd_host)
free(m_mgmd_host);
if (m_config_retriever) {
delete m_config_retriever;
}
......@@ -193,7 +189,6 @@ Configuration::fetch_configuration(){
}
m_mgmd_port= 0;
m_mgmd_host= 0;
m_config_retriever= new ConfigRetriever(getConnectString(),
NDB_VERSION, NODE_TYPE_DB);
......@@ -214,16 +209,8 @@ Configuration::fetch_configuration(){
ERROR_SET(fatal, ERR_INVALID_CONFIG, "Could not connect to ndb_mgmd", s);
}
{
m_mgmd_port= m_config_retriever->get_mgmd_port();
/**
* We copy the mgmd host as the handle is later
* destroyed, so a pointer won't work
*/
int len= strlen(m_config_retriever->get_mgmd_host());
m_mgmd_host= (char*)malloc(sizeof(char)*len);
strcpy(m_mgmd_host,m_config_retriever->get_mgmd_host());
}
m_mgmd_host.assign(m_config_retriever->get_mgmd_host());
ConfigRetriever &cr= *m_config_retriever;
......@@ -325,10 +312,6 @@ Configuration::setupConfiguration(){
ERROR_SET(fatal, ERR_INVALID_CONFIG, "Invalid configuration fetched",
"No transporters configured");
}
if(!globalTransporterRegistry.connect_client(
m_config_retriever->get_mgmHandlePtr()))
ERROR_SET(fatal, ERR_INVALID_CONFIG, "Connection to mgmd terminated before setup was complete",
"StopOnError missing");
}
/**
......
......@@ -17,6 +17,7 @@
#ifndef Configuration_H
#define Configuration_H
#include <util/BaseString.hpp>
#include <mgmapi.h>
#include <ndb_types.h>
......@@ -67,7 +68,7 @@ public:
const ndb_mgm_configuration_iterator * getOwnConfigIterator() const;
Uint32 get_mgmd_port() const {return m_mgmd_port;};
char *get_mgmd_host() const {return m_mgmd_host;};
const char *get_mgmd_host() const {return m_mgmd_host.c_str();};
ConfigRetriever* get_config_retriever() { return m_config_retriever; };
class LogLevel * m_logLevel;
......@@ -99,7 +100,7 @@ private:
bool _initialStart;
char * _connectString;
Uint32 m_mgmd_port;
char *m_mgmd_host;
BaseString m_mgmd_host;
bool _daemonMode;
void calcSizeAlt(class ConfigValues * );
......
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