diff options
author | jonas@perch.ndb.mysql.com <> | 2006-10-04 10:19:08 +0200 |
---|---|---|
committer | jonas@perch.ndb.mysql.com <> | 2006-10-04 10:19:08 +0200 |
commit | 57dd1481aefd622f51c46e9a22abe06474e2801a (patch) | |
tree | 8ff68c99465e3840cb88e8f46d7777ef191ba4cb /ndb/src/common | |
parent | b52d86cff36b747e7fc9a1dcefddf614c1928a27 (diff) | |
parent | 9c87453bfa8163aa98f95f9caddda9898c1498e8 (diff) | |
download | mariadb-git-57dd1481aefd622f51c46e9a22abe06474e2801a.tar.gz |
Merge perch.ndb.mysql.com:/home/jonas/src/mysql-5.0-ndb-bj
into perch.ndb.mysql.com:/home/jonas/src/mysql-5.0-ndb
Diffstat (limited to 'ndb/src/common')
-rw-r--r-- | ndb/src/common/debugger/signaldata/SignalNames.cpp | 3 | ||||
-rw-r--r-- | ndb/src/common/mgmcommon/ConfigRetriever.cpp | 12 | ||||
-rw-r--r-- | ndb/src/common/transporter/Transporter.cpp | 18 | ||||
-rw-r--r-- | ndb/src/common/util/SocketClient.cpp | 73 |
4 files changed, 91 insertions, 15 deletions
diff --git a/ndb/src/common/debugger/signaldata/SignalNames.cpp b/ndb/src/common/debugger/signaldata/SignalNames.cpp index 49e3f505b11..ecc9fc83153 100644 --- a/ndb/src/common/debugger/signaldata/SignalNames.cpp +++ b/ndb/src/common/debugger/signaldata/SignalNames.cpp @@ -636,6 +636,7 @@ const GsnName SignalNames [] = { ,{ GSN_DICT_LOCK_CONF, "DICT_LOCK_CONF" } ,{ GSN_DICT_LOCK_REF, "DICT_LOCK_REF" } ,{ GSN_DICT_UNLOCK_ORD, "DICT_UNLOCK_ORD" } - + + ,{ GSN_UPDATE_FRAG_DIST_KEY_ORD, "UPDATE_FRAG_DIST_KEY_ORD" } }; const unsigned short NO_OF_SIGNAL_NAMES = sizeof(SignalNames)/sizeof(GsnName); diff --git a/ndb/src/common/mgmcommon/ConfigRetriever.cpp b/ndb/src/common/mgmcommon/ConfigRetriever.cpp index c2b3e8235eb..a0e3a4b74f3 100644 --- a/ndb/src/common/mgmcommon/ConfigRetriever.cpp +++ b/ndb/src/common/mgmcommon/ConfigRetriever.cpp @@ -45,7 +45,8 @@ //**************************************************************************** ConfigRetriever::ConfigRetriever(const char * _connect_string, - Uint32 version, Uint32 node_type) + Uint32 version, Uint32 node_type, + const char * _bindaddress) { DBUG_ENTER("ConfigRetriever::ConfigRetriever"); @@ -66,6 +67,15 @@ ConfigRetriever::ConfigRetriever(const char * _connect_string, setError(CR_ERROR, ndb_mgm_get_latest_error_desc(m_handle)); DBUG_VOID_RETURN; } + + if (_bindaddress) + { + if (ndb_mgm_set_bindaddress(m_handle, _bindaddress)) + { + setError(CR_ERROR, ndb_mgm_get_latest_error_desc(m_handle)); + DBUG_VOID_RETURN; + } + } resetError(); DBUG_VOID_RETURN; } diff --git a/ndb/src/common/transporter/Transporter.cpp b/ndb/src/common/transporter/Transporter.cpp index 820aa4cfc18..383456f1077 100644 --- a/ndb/src/common/transporter/Transporter.cpp +++ b/ndb/src/common/transporter/Transporter.cpp @@ -60,9 +60,6 @@ Transporter::Transporter(TransporterRegistry &t_reg, } strncpy(localHostName, lHostName, sizeof(localHostName)); - if (strlen(lHostName) > 0) - Ndb_getInAddr(&localHostAddress, lHostName); - DBUG_PRINT("info",("rId=%d lId=%d isServer=%d rHost=%s lHost=%s s_port=%d", remoteNodeId, localNodeId, isServer, remoteHostName, localHostName, @@ -128,10 +125,23 @@ Transporter::connect_client() { return true; if(isMgmConnection) + { sockfd= m_transporter_registry.connect_ndb_mgmd(m_socket_client); + } else + { + if (!m_socket_client->init()) + { + return false; + } + if (strlen(localHostName) > 0) + { + if (m_socket_client->bind(localHostName, 0) != 0) + return false; + } sockfd= m_socket_client->connect(); - + } + return connect_client(sockfd); } diff --git a/ndb/src/common/util/SocketClient.cpp b/ndb/src/common/util/SocketClient.cpp index 821624eb5c4..f4f2babf312 100644 --- a/ndb/src/common/util/SocketClient.cpp +++ b/ndb/src/common/util/SocketClient.cpp @@ -25,7 +25,7 @@ SocketClient::SocketClient(const char *server_name, unsigned short port, SocketA { m_auth= sa; m_port= port; - m_server_name= strdup(server_name); + m_server_name= server_name ? strdup(server_name) : 0; m_sockfd= NDB_INVALID_SOCKET; } @@ -45,13 +45,16 @@ SocketClient::init() if (m_sockfd != NDB_INVALID_SOCKET) NDB_CLOSE_SOCKET(m_sockfd); - memset(&m_servaddr, 0, sizeof(m_servaddr)); - m_servaddr.sin_family = AF_INET; - m_servaddr.sin_port = htons(m_port); - // Convert ip address presentation format to numeric format - if (Ndb_getInAddr(&m_servaddr.sin_addr, m_server_name)) - return false; - + if (m_server_name) + { + memset(&m_servaddr, 0, sizeof(m_servaddr)); + m_servaddr.sin_family = AF_INET; + m_servaddr.sin_port = htons(m_port); + // Convert ip address presentation format to numeric format + if (Ndb_getInAddr(&m_servaddr.sin_addr, m_server_name)) + return false; + } + m_sockfd= socket(AF_INET, SOCK_STREAM, 0); if (m_sockfd == NDB_INVALID_SOCKET) { return false; @@ -62,8 +65,45 @@ SocketClient::init() return true; } +int +SocketClient::bind(const char* bindaddress, unsigned short localport) +{ + if (m_sockfd == NDB_INVALID_SOCKET) + return -1; + + struct sockaddr_in local; + memset(&local, 0, sizeof(local)); + local.sin_family = AF_INET; + local.sin_port = htons(localport); + // Convert ip address presentation format to numeric format + if (Ndb_getInAddr(&local.sin_addr, bindaddress)) + { + return errno ? errno : EINVAL; + } + + const int on = 1; + if (setsockopt(m_sockfd, SOL_SOCKET, SO_REUSEADDR, + (const char*)&on, sizeof(on)) == -1) { + + int ret = errno; + NDB_CLOSE_SOCKET(m_sockfd); + m_sockfd= NDB_INVALID_SOCKET; + return errno; + } + + if (::bind(m_sockfd, (struct sockaddr*)&local, sizeof(local)) == -1) + { + int ret = errno; + NDB_CLOSE_SOCKET(m_sockfd); + m_sockfd= NDB_INVALID_SOCKET; + return ret; + } + + return 0; +} + NDB_SOCKET_TYPE -SocketClient::connect() +SocketClient::connect(const char *toaddress, unsigned short toport) { if (m_sockfd == NDB_INVALID_SOCKET) { @@ -74,6 +114,21 @@ SocketClient::connect() return NDB_INVALID_SOCKET; } } + + if (toaddress) + { + if (m_server_name) + free(m_server_name); + m_server_name = strdup(toaddress); + m_port = toport; + memset(&m_servaddr, 0, sizeof(m_servaddr)); + m_servaddr.sin_family = AF_INET; + m_servaddr.sin_port = htons(toport); + // Convert ip address presentation format to numeric format + if (Ndb_getInAddr(&m_servaddr.sin_addr, m_server_name)) + return NDB_INVALID_SOCKET; + } + const int r = ::connect(m_sockfd, (struct sockaddr*) &m_servaddr, sizeof(m_servaddr)); if (r == -1) { NDB_CLOSE_SOCKET(m_sockfd); |