summaryrefslogtreecommitdiff
path: root/ndb/src/kernel/vm
diff options
context:
space:
mode:
authorunknown <stewart@mysql.com>2005-02-24 17:57:22 +1100
committerunknown <stewart@mysql.com>2005-02-24 17:57:22 +1100
commit9bc6ed86cc03a094f55f6702e47b80ec4baa7778 (patch)
tree3c555a4ea52430ed6f61cbf7a269961550fd91fb /ndb/src/kernel/vm
parentbb5a2f280f41178cb132e6c0e9db205cbc4abc9f (diff)
downloadmariadb-git-9bc6ed86cc03a094f55f6702e47b80ec4baa7778.tar.gz
Fixes for: use initial mgm connection as transporter connection
ndb/include/mgmapi/mgmapi.h: ndb_mgm_convert_to_transporter may destroy the handle, now takes a pointer. ndb/include/mgmcommon/ConfigRetriever.hpp: If outside code is going to manipulate the NdbMgmHandle, allow it to do it via a get_mgmHandlePtr() call ndb/include/transporter/TransporterRegistry.hpp: connect_client and connect_ndb_mgmd may destroy the handle, now they take a pointer. ndb/src/common/transporter/TransporterRegistry.cpp: When start_service is binding to ports, report back the port numbers. We need this here now, as we re-use the initial mgm connection as a transporter, which is connected *before* start_service has allocated the dynamic port numbers. So the creation of this early transporter cannot be used to send the dynamic ports to the mgmd. We connect to the mgm server (using the handle that will be used in the client_Connect thread) if needed. This is thread safe as start_service is only ever called once, before the client connect thread starts. connect_client,connect_ndb_mgmd may destroy the NdbMgmHandle. It now accepts a pointer to it. ndb/src/kernel/vm/Configuration.cpp: Copy the m_mgmd_host string from the config_retreiver as the NdbMgmHandle in the ConfigRetreiver will be destroyed later (along with the host string). globalTransporterRegistry.connect_client will destroy the mgm handle, use a pointer to the handle. ndb/src/kernel/vm/Configuration.hpp: allow the dynamic allocation of m_mgmd_host. ndb/src/mgmapi/mgmapi.cpp: accept a pointer for ndb_mgm_convert_to_transporter as we destroy the handle.
Diffstat (limited to 'ndb/src/kernel/vm')
-rw-r--r--ndb/src/kernel/vm/Configuration.cpp19
-rw-r--r--ndb/src/kernel/vm/Configuration.hpp4
2 files changed, 18 insertions, 5 deletions
diff --git a/ndb/src/kernel/vm/Configuration.cpp b/ndb/src/kernel/vm/Configuration.cpp
index 02f4f2a9b98..29455e5b115 100644
--- a/ndb/src/kernel/vm/Configuration.cpp
+++ b/ndb/src/kernel/vm/Configuration.cpp
@@ -154,6 +154,7 @@ Configuration::Configuration()
m_config_retriever= 0;
m_clusterConfig= 0;
m_clusterConfigIter= 0;
+ m_mgmd_host= NULL;
}
Configuration::~Configuration(){
@@ -166,6 +167,9 @@ Configuration::~Configuration(){
if(_backupPath != NULL)
free(_backupPath);
+ if(m_mgmd_host)
+ free(m_mgmd_host);
+
if (m_config_retriever) {
delete m_config_retriever;
}
@@ -210,8 +214,16 @@ 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();
- m_mgmd_host= m_config_retriever->get_mgmd_host();
+ {
+ 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());
+ }
ConfigRetriever &cr= *m_config_retriever;
@@ -313,7 +325,8 @@ Configuration::setupConfiguration(){
ERROR_SET(fatal, ERR_INVALID_CONFIG, "Invalid configuration fetched",
"No transporters configured");
}
- if(!globalTransporterRegistry.connect_client(m_config_retriever->get_mgmHandle()))
+ 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");
}
diff --git a/ndb/src/kernel/vm/Configuration.hpp b/ndb/src/kernel/vm/Configuration.hpp
index a257881e353..dd690665413 100644
--- a/ndb/src/kernel/vm/Configuration.hpp
+++ b/ndb/src/kernel/vm/Configuration.hpp
@@ -67,7 +67,7 @@ public:
const ndb_mgm_configuration_iterator * getOwnConfigIterator() const;
Uint32 get_mgmd_port() const {return m_mgmd_port;};
- const char *get_mgmd_host() const {return m_mgmd_host;};
+ char *get_mgmd_host() const {return m_mgmd_host;};
ConfigRetriever* get_config_retriever() { return m_config_retriever; };
class LogLevel * m_logLevel;
@@ -99,7 +99,7 @@ private:
bool _initialStart;
char * _connectString;
Uint32 m_mgmd_port;
- const char *m_mgmd_host;
+ char *m_mgmd_host;
bool _daemonMode;
void calcSizeAlt(class ConfigValues * );