summaryrefslogtreecommitdiff
path: root/ndb/src/common
diff options
context:
space:
mode:
authorunknown <tomas@poseidon.ndb.mysql.com>2005-07-15 17:14:34 +0200
committerunknown <tomas@poseidon.ndb.mysql.com>2005-07-15 17:14:34 +0200
commit148de25d06f33b50ea294397d40e4258581a8862 (patch)
tree7e094961a3f395ec699e1dae6be0a679aed33e9f /ndb/src/common
parentb9cfd031813bf56c9cce47303cc9d5313aaf2f19 (diff)
parent5536725d22349413fbc688900cb91dc33a32f470 (diff)
downloadmariadb-git-148de25d06f33b50ea294397d40e4258581a8862.tar.gz
Merge tulin@bk-internal.mysql.com:/home/bk/mysql-5.0
into poseidon.ndb.mysql.com:/home/tomas/mysql-5.0
Diffstat (limited to 'ndb/src/common')
-rw-r--r--ndb/src/common/logger/LogHandler.cpp1
-rw-r--r--ndb/src/common/mgmcommon/ConfigRetriever.cpp17
-rw-r--r--ndb/src/common/portlib/NdbMutex.c16
-rw-r--r--ndb/src/common/portlib/NdbTCP.cpp9
-rw-r--r--ndb/src/common/portlib/NdbThread.c16
-rw-r--r--ndb/src/common/transporter/Transporter.cpp15
-rw-r--r--ndb/src/common/transporter/Transporter.hpp1
-rw-r--r--ndb/src/common/transporter/TransporterRegistry.cpp18
-rw-r--r--ndb/src/common/util/Parser.cpp21
-rw-r--r--ndb/src/common/util/SocketClient.cpp2
-rw-r--r--ndb/src/common/util/SocketServer.cpp4
-rw-r--r--ndb/src/common/util/version.c12
12 files changed, 100 insertions, 32 deletions
diff --git a/ndb/src/common/logger/LogHandler.cpp b/ndb/src/common/logger/LogHandler.cpp
index ec4137297f1..a9d4512112f 100644
--- a/ndb/src/common/logger/LogHandler.cpp
+++ b/ndb/src/common/logger/LogHandler.cpp
@@ -31,6 +31,7 @@ LogHandler::LogHandler() :
m_last_message[0]= 0;
m_last_log_time= 0;
m_now= 0;
+ m_last_level= (Logger::LoggerLevel)-1;
}
LogHandler::~LogHandler()
diff --git a/ndb/src/common/mgmcommon/ConfigRetriever.cpp b/ndb/src/common/mgmcommon/ConfigRetriever.cpp
index 0e9b2a83e2f..b3d0221fedb 100644
--- a/ndb/src/common/mgmcommon/ConfigRetriever.cpp
+++ b/ndb/src/common/mgmcommon/ConfigRetriever.cpp
@@ -47,6 +47,8 @@
ConfigRetriever::ConfigRetriever(const char * _connect_string,
Uint32 version, Uint32 node_type)
{
+ DBUG_ENTER("ConfigRetriever::ConfigRetriever");
+
m_version = version;
m_node_type = node_type;
_ownNodeId= 0;
@@ -55,23 +57,26 @@ ConfigRetriever::ConfigRetriever(const char * _connect_string,
if (m_handle == 0) {
setError(CR_ERROR, "Unable to allocate mgm handle");
- return;
+ DBUG_VOID_RETURN;
}
if (ndb_mgm_set_connectstring(m_handle, _connect_string))
{
setError(CR_ERROR, ndb_mgm_get_latest_error_desc(m_handle));
- return;
+ DBUG_VOID_RETURN;
}
resetError();
+ DBUG_VOID_RETURN;
}
ConfigRetriever::~ConfigRetriever()
{
+ DBUG_ENTER("ConfigRetriever::~ConfigRetriever");
if (m_handle) {
ndb_mgm_disconnect(m_handle);
ndb_mgm_destroy_handle(&m_handle);
}
+ DBUG_VOID_RETURN;
}
Uint32
@@ -137,14 +142,14 @@ ConfigRetriever::getConfig() {
}
ndb_mgm_configuration *
-ConfigRetriever::getConfig(NdbMgmHandle m_handle){
-
+ConfigRetriever::getConfig(NdbMgmHandle m_handle)
+{
ndb_mgm_configuration * conf = ndb_mgm_get_configuration(m_handle,m_version);
- if(conf == 0){
+ if(conf == 0)
+ {
setError(CR_ERROR, ndb_mgm_get_latest_error_desc(m_handle));
return 0;
}
-
return conf;
}
diff --git a/ndb/src/common/portlib/NdbMutex.c b/ndb/src/common/portlib/NdbMutex.c
index d3d39ea8cf7..18f8548e4e6 100644
--- a/ndb/src/common/portlib/NdbMutex.c
+++ b/ndb/src/common/portlib/NdbMutex.c
@@ -23,33 +23,37 @@
NdbMutex* NdbMutex_Create(void)
{
+ DBUG_ENTER("NdbMutex_Create");
NdbMutex* pNdbMutex;
int result;
pNdbMutex = (NdbMutex*)NdbMem_Allocate(sizeof(NdbMutex));
+ DBUG_PRINT("info",("NdbMem_Allocate 0x%lx",pNdbMutex));
if (pNdbMutex == NULL)
- return NULL;
+ DBUG_RETURN(NULL);
result = pthread_mutex_init(pNdbMutex, NULL);
assert(result == 0);
- return pNdbMutex;
-
+ DBUG_RETURN(pNdbMutex);
}
int NdbMutex_Destroy(NdbMutex* p_mutex)
{
+ DBUG_ENTER("NdbMutex_Destroy");
int result;
if (p_mutex == NULL)
- return -1;
+ DBUG_RETURN(-1);
result = pthread_mutex_destroy(p_mutex);
- free(p_mutex);
+
+ DBUG_PRINT("info",("NdbMem_Free 0x%lx",p_mutex));
+ NdbMem_Free(p_mutex);
- return result;
+ DBUG_RETURN(result);
}
diff --git a/ndb/src/common/portlib/NdbTCP.cpp b/ndb/src/common/portlib/NdbTCP.cpp
index a63f5a7ba27..c7b9d33c5f6 100644
--- a/ndb/src/common/portlib/NdbTCP.cpp
+++ b/ndb/src/common/portlib/NdbTCP.cpp
@@ -54,6 +54,15 @@ Ndb_getInAddr(struct in_addr * dst, const char *address) {
return -1; //DBUG_RETURN(-1);
}
+#ifndef DBUG_OFF
+extern "C"
+int NDB_CLOSE_SOCKET(int fd)
+{
+ DBUG_PRINT("info", ("NDB_CLOSE_SOCKET(%d)", fd));
+ return _NDB_CLOSE_SOCKET(fd);
+}
+#endif
+
#if 0
int
Ndb_getInAddr(struct in_addr * dst, const char *address) {
diff --git a/ndb/src/common/portlib/NdbThread.c b/ndb/src/common/portlib/NdbThread.c
index aaee9b45069..cee4ec018a0 100644
--- a/ndb/src/common/portlib/NdbThread.c
+++ b/ndb/src/common/portlib/NdbThread.c
@@ -56,6 +56,7 @@ ndb_thread_wrapper(void* _ss){
void *ret;
struct NdbThread * ss = (struct NdbThread *)_ss;
ret= (* ss->func)(ss->object);
+ DBUG_POP();
NdbThread_Exit(ret);
}
/* will never be reached */
@@ -70,6 +71,7 @@ struct NdbThread* NdbThread_Create(NDB_THREAD_FUNC *p_thread_func,
const char* p_thread_name,
NDB_THREAD_PRIO thread_prio)
{
+ DBUG_ENTER("NdbThread_Create");
struct NdbThread* tmpThread;
int result;
pthread_attr_t thread_attr;
@@ -77,11 +79,13 @@ struct NdbThread* NdbThread_Create(NDB_THREAD_FUNC *p_thread_func,
(void)thread_prio; /* remove warning for unused parameter */
if (p_thread_func == NULL)
- return 0;
+ DBUG_RETURN(NULL);
tmpThread = (struct NdbThread*)NdbMem_Allocate(sizeof(struct NdbThread));
if (tmpThread == NULL)
- return NULL;
+ DBUG_RETURN(NULL);
+
+ DBUG_PRINT("info",("thread_name: %s", p_thread_name));
strnmov(tmpThread->thread_name,p_thread_name,sizeof(tmpThread->thread_name));
@@ -108,16 +112,20 @@ struct NdbThread* NdbThread_Create(NDB_THREAD_FUNC *p_thread_func,
assert(result==0);
pthread_attr_destroy(&thread_attr);
- return tmpThread;
+ DBUG_PRINT("exit",("ret: %lx", tmpThread));
+ DBUG_RETURN(tmpThread);
}
void NdbThread_Destroy(struct NdbThread** p_thread)
{
- if (*p_thread != NULL){
+ DBUG_ENTER("NdbThread_Destroy");
+ if (*p_thread != NULL){
+ DBUG_PRINT("enter",("*p_thread: %lx", * p_thread));
free(* p_thread);
* p_thread = 0;
}
+ DBUG_VOID_RETURN;
}
diff --git a/ndb/src/common/transporter/Transporter.cpp b/ndb/src/common/transporter/Transporter.cpp
index 124ed5f7241..377fabe27ab 100644
--- a/ndb/src/common/transporter/Transporter.cpp
+++ b/ndb/src/common/transporter/Transporter.cpp
@@ -76,6 +76,7 @@ Transporter::Transporter(TransporterRegistry &t_reg,
m_connected = false;
m_timeOutMillis = 1000;
+ m_connect_address.s_addr= 0;
if(s_port<0)
s_port= -s_port; // was dynamic
@@ -103,6 +104,13 @@ Transporter::connect_server(NDB_SOCKET_TYPE sockfd) {
DBUG_RETURN(true); // TODO assert(0);
}
+ {
+ struct sockaddr addr;
+ SOCKET_SIZE_TYPE addrlen= sizeof(addr);
+ int r= getpeername(sockfd, &addr, &addrlen);
+ m_connect_address= ((struct sockaddr_in *)&addr)->sin_addr;
+ }
+
bool res = connect_server_impl(sockfd);
if(res){
m_connected = true;
@@ -189,6 +197,13 @@ Transporter::connect_client(NDB_SOCKET_TYPE sockfd) {
g_eventLogger.warning("Unable to verify transporter compatability with node %d", nodeId);
}
+ {
+ struct sockaddr addr;
+ SOCKET_SIZE_TYPE addrlen= sizeof(addr);
+ int r= getpeername(sockfd, &addr, &addrlen);
+ m_connect_address= ((struct sockaddr_in *)&addr)->sin_addr;
+ }
+
bool res = connect_client_impl(sockfd);
if(res){
m_connected = true;
diff --git a/ndb/src/common/transporter/Transporter.hpp b/ndb/src/common/transporter/Transporter.hpp
index 8c5e96226a3..c9f4e9bda42 100644
--- a/ndb/src/common/transporter/Transporter.hpp
+++ b/ndb/src/common/transporter/Transporter.hpp
@@ -147,6 +147,7 @@ private:
bool isMgmConnection;
SocketClient *m_socket_client;
+ struct in_addr m_connect_address;
protected:
Uint32 getErrorCount();
diff --git a/ndb/src/common/transporter/TransporterRegistry.cpp b/ndb/src/common/transporter/TransporterRegistry.cpp
index 3776bce7452..60649665d4a 100644
--- a/ndb/src/common/transporter/TransporterRegistry.cpp
+++ b/ndb/src/common/transporter/TransporterRegistry.cpp
@@ -55,6 +55,12 @@ extern int g_ndb_shm_signum;
#include <EventLogger.hpp>
extern EventLogger g_eventLogger;
+struct in_addr
+TransporterRegistry::get_connect_address(NodeId node_id) const
+{
+ return theTransporters[node_id]->m_connect_address;
+}
+
SocketServer::Session * TransporterService::newSession(NDB_SOCKET_TYPE sockfd)
{
DBUG_ENTER("SocketServer::Session * TransporterService::newSession");
@@ -74,7 +80,9 @@ SocketServer::Session * TransporterService::newSession(NDB_SOCKET_TYPE sockfd)
TransporterRegistry::TransporterRegistry(void * callback,
unsigned _maxTransporters,
- unsigned sizeOfLongSignalMemory) {
+ unsigned sizeOfLongSignalMemory)
+{
+ DBUG_ENTER("TransporterRegistry::TransporterRegistry");
nodeIdSpecified = false;
maxTransporters = _maxTransporters;
@@ -112,6 +120,8 @@ TransporterRegistry::TransporterRegistry(void * callback,
theOSEReceiver = 0;
theOSEJunkSocketSend = 0;
theOSEJunkSocketRecv = 0;
+
+ DBUG_VOID_RETURN;
}
void TransporterRegistry::set_mgm_handle(NdbMgmHandle h)
@@ -135,7 +145,9 @@ void TransporterRegistry::set_mgm_handle(NdbMgmHandle h)
DBUG_VOID_RETURN;
}
-TransporterRegistry::~TransporterRegistry() {
+TransporterRegistry::~TransporterRegistry()
+{
+ DBUG_ENTER("TransporterRegistry::~TransporterRegistry");
removeAll();
@@ -157,6 +169,8 @@ TransporterRegistry::~TransporterRegistry() {
#endif
if (m_mgm_handle)
ndb_mgm_destroy_handle(&m_mgm_handle);
+
+ DBUG_VOID_RETURN;
}
void
diff --git a/ndb/src/common/util/Parser.cpp b/ndb/src/common/util/Parser.cpp
index dea128ccf66..d692aa18392 100644
--- a/ndb/src/common/util/Parser.cpp
+++ b/ndb/src/common/util/Parser.cpp
@@ -141,7 +141,10 @@ split(char * buf, char ** name, char ** value){
bool
ParserImpl::run(Context * ctx, const class Properties ** pDst,
- volatile bool * stop) const {
+ volatile bool * stop) const
+{
+ DBUG_ENTER("ParserImpl::run");
+
* pDst = 0;
bool ownStop = false;
if(stop == 0)
@@ -153,24 +156,24 @@ ParserImpl::run(Context * ctx, const class Properties ** pDst,
ctx->m_currentToken = input.gets(ctx->m_tokenBuffer, sz);
if(Eof(ctx->m_currentToken)){
ctx->m_status = Parser<Dummy>::Eof;
- return false;
+ DBUG_RETURN(false);
}
if(ctx->m_currentToken[0] == 0){
ctx->m_status = Parser<Dummy>::NoLine;
- return false;
+ DBUG_RETURN(false);
}
if(Empty(ctx->m_currentToken)){
ctx->m_status = Parser<Dummy>::EmptyLine;
- return false;
+ DBUG_RETURN(false);
}
trim(ctx->m_currentToken);
ctx->m_currentCmd = matchCommand(ctx, ctx->m_currentToken, m_rows);
if(ctx->m_currentCmd == 0){
ctx->m_status = Parser<Dummy>::UnknownCommand;
- return false;
+ DBUG_RETURN(false);
}
Properties * p = new Properties();
@@ -200,19 +203,19 @@ ParserImpl::run(Context * ctx, const class Properties ** pDst,
tmp = input.gets(buf, sz);
} while((! * stop) && !Eof(tmp) && !Empty(tmp));
}
- return false;
+ DBUG_RETURN(false);
}
if(* stop){
delete p;
ctx->m_status = Parser<Dummy>::ExternalStop;
- return false;
+ DBUG_RETURN(false);
}
if(!checkMandatory(ctx, p)){
ctx->m_status = Parser<Dummy>::MissingMandatoryArgument;
delete p;
- return false;
+ DBUG_RETURN(false);
}
/**
@@ -229,7 +232,7 @@ ParserImpl::run(Context * ctx, const class Properties ** pDst,
ctx->m_status = Parser<Dummy>::Ok;
* pDst = p;
- return true;
+ DBUG_RETURN(true);
}
const ParserImpl::DummyRow*
diff --git a/ndb/src/common/util/SocketClient.cpp b/ndb/src/common/util/SocketClient.cpp
index 38df1417eb8..821624eb5c4 100644
--- a/ndb/src/common/util/SocketClient.cpp
+++ b/ndb/src/common/util/SocketClient.cpp
@@ -57,6 +57,8 @@ SocketClient::init()
return false;
}
+ DBUG_PRINT("info",("NDB_SOCKET: %d", m_sockfd));
+
return true;
}
diff --git a/ndb/src/common/util/SocketServer.cpp b/ndb/src/common/util/SocketServer.cpp
index 6019d24d736..15dca2d96b1 100644
--- a/ndb/src/common/util/SocketServer.cpp
+++ b/ndb/src/common/util/SocketServer.cpp
@@ -64,6 +64,8 @@ SocketServer::tryBind(unsigned short port, const char * intface) {
return false;
}
+ DBUG_PRINT("info",("NDB_SOCKET: %d", sock));
+
const int on = 1;
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
(const char*)&on, sizeof(on)) == -1) {
@@ -104,6 +106,8 @@ SocketServer::setup(SocketServer::Service * service,
DBUG_RETURN(false);
}
+ DBUG_PRINT("info",("NDB_SOCKET: %d", sock));
+
const int on = 1;
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
(const char*)&on, sizeof(on)) == -1) {
diff --git a/ndb/src/common/util/version.c b/ndb/src/common/util/version.c
index 5883a709e96..a7e103c3dab 100644
--- a/ndb/src/common/util/version.c
+++ b/ndb/src/common/util/version.c
@@ -38,22 +38,24 @@ Uint32 makeVersion(Uint32 major, Uint32 minor, Uint32 build) {
}
-const char * getVersionString(Uint32 version, const char * status) {
- char buff[100];
+char ndb_version_string_buf[NDB_VERSION_STRING_BUF_SZ];
+const char * getVersionString(Uint32 version, const char * status,
+ char *buf, unsigned sz)
+{
if (status && status[0] != 0)
- basestring_snprintf(buff, sizeof(buff),
+ basestring_snprintf(buf, sz,
"Version %d.%d.%d (%s)",
getMajor(version),
getMinor(version),
getBuild(version),
status);
else
- basestring_snprintf(buff, sizeof(buff),
+ basestring_snprintf(buf, sz,
"Version %d.%d.%d",
getMajor(version),
getMinor(version),
getBuild(version));
- return strdup(buff);
+ return buf;
}
typedef enum {