Skip to content

Commit ce6f050

Browse files
author
jonas oreland
committed
ndb - merge 63 to 70
2 parents eb08d1d + a38ea08 commit ce6f050

File tree

7 files changed

+41
-14
lines changed

7 files changed

+41
-14
lines changed

storage/ndb/include/transporter/TransporterRegistry.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class TransporterRegistry : private TransporterSendBufferHandle {
118118
NOTE! Connection should be closed if function
119119
returns false
120120
*/
121-
bool connect_server(NDB_SOCKET_TYPE sockfd) const;
121+
bool connect_server(NDB_SOCKET_TYPE sockfd, BaseString& errormsg) const;
122122

123123
bool connect_client(NdbMgmHandle *h);
124124

storage/ndb/src/common/transporter/Transporter.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -130,18 +130,25 @@ Transporter::configure(const TransporterConfiguration* conf)
130130

131131

132132
bool
133-
Transporter::connect_server(NDB_SOCKET_TYPE sockfd) {
133+
Transporter::connect_server(NDB_SOCKET_TYPE sockfd,
134+
BaseString& msg) {
134135
// all initial negotiation is done in TransporterRegistry::connect_server
135136
DBUG_ENTER("Transporter::connect_server");
136137

137-
if(m_connected)
138+
if (m_connected)
139+
{
140+
msg.assfmt("line: %u : already connected ??", __LINE__);
138141
DBUG_RETURN(false);
142+
}
139143

140144
// Cache the connect address
141145
my_socket_connect_address(sockfd, &m_connect_address);
142146

143147
if (!connect_server_impl(sockfd))
148+
{
149+
msg.assfmt("line: %u : connect_server_impl failed", __LINE__);
144150
DBUG_RETURN(false);
151+
}
145152

146153
m_connected = true;
147154

storage/ndb/src/common/transporter/Transporter.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class Transporter {
4949
*/
5050
virtual bool connect_client();
5151
bool connect_client(NDB_SOCKET_TYPE sockfd);
52-
bool connect_server(NDB_SOCKET_TYPE socket);
52+
bool connect_server(NDB_SOCKET_TYPE socket, BaseString& errormsg);
5353

5454
/**
5555
* Blocking

storage/ndb/src/common/transporter/TransporterRegistry.cpp

+21-3
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ SocketServer::Session * TransporterService::newSession(NDB_SOCKET_TYPE sockfd)
6464
DBUG_RETURN(0);
6565
}
6666

67-
if (!m_transporter_registry->connect_server(sockfd))
67+
BaseString msg;
68+
if (!m_transporter_registry->connect_server(sockfd, msg))
6869
{
6970
NDB_CLOSE_SOCKET(sockfd);
7071
DBUG_RETURN(0);
@@ -305,7 +306,8 @@ TransporterRegistry::init(NodeId nodeId) {
305306
}
306307

307308
bool
308-
TransporterRegistry::connect_server(NDB_SOCKET_TYPE sockfd) const
309+
TransporterRegistry::connect_server(NDB_SOCKET_TYPE sockfd,
310+
BaseString & msg) const
309311
{
310312
DBUG_ENTER("TransporterRegistry::connect_server(sockfd)");
311313

@@ -314,6 +316,7 @@ TransporterRegistry::connect_server(NDB_SOCKET_TYPE sockfd) const
314316
SocketInputStream s_input(sockfd);
315317
char buf[11+1+11+1]; // <int> <int>
316318
if (s_input.gets(buf, sizeof(buf)) == 0) {
319+
msg.assfmt("line: %u : Failed to get nodeid from client", __LINE__);
317320
DBUG_PRINT("error", ("Failed to read 'hello' from client"));
318321
DBUG_RETURN(false);
319322
}
@@ -328,6 +331,7 @@ TransporterRegistry::connect_server(NDB_SOCKET_TYPE sockfd) const
328331
// ok, but with no checks on transporter configuration compatability
329332
break;
330333
default:
334+
msg.assfmt("line: %u : Incorrect reply from client: >%s<", __LINE__, buf);
331335
DBUG_PRINT("error", ("Failed to parse 'hello' from client, buf: '%.*s'",
332336
(int)sizeof(buf), buf));
333337
DBUG_RETURN(false);
@@ -341,6 +345,7 @@ TransporterRegistry::connect_server(NDB_SOCKET_TYPE sockfd) const
341345
if (nodeId < 0 ||
342346
nodeId >= (int)maxTransporters)
343347
{
348+
msg.assfmt("line: %u : Incorrect reply from client: >%s<", __LINE__, buf);
344349
DBUG_PRINT("error", ("Out of range nodeId: %d from client",
345350
nodeId));
346351
DBUG_RETURN(false);
@@ -350,13 +355,20 @@ TransporterRegistry::connect_server(NDB_SOCKET_TYPE sockfd) const
350355
Transporter *t= theTransporters[nodeId];
351356
if (t == 0)
352357
{
358+
msg.assfmt("line: %u : Incorrect reply from client: >%s<, node: %u",
359+
__LINE__, buf, nodeId);
353360
DBUG_PRINT("error", ("No transporter available for node id %d", nodeId));
354361
DBUG_RETURN(false);
355362
}
356363

357364
// Check that the transporter should be connecting
358365
if (performStates[nodeId] != TransporterRegistry::CONNECTING)
359366
{
367+
msg.assfmt("line: %u : Incorrect state for node %u state: %s (%u)",
368+
__LINE__, nodeId,
369+
getPerformStateString(performStates[nodeId]),
370+
performStates[nodeId]);
371+
360372
DBUG_PRINT("error", ("Transporter for node id %d in wrong state",
361373
nodeId));
362374
DBUG_RETURN(false);
@@ -376,15 +388,21 @@ TransporterRegistry::connect_server(NDB_SOCKET_TYPE sockfd) const
376388
SocketOutputStream s_output(sockfd);
377389
if (s_output.println("%d %d", t->getLocalNodeId(), t->m_type) < 0)
378390
{
391+
msg.assfmt("line: %u : Failed to reply to connecting socket (node: %u)",
392+
__LINE__, nodeId);
379393
DBUG_PRINT("error", ("Send of reply failed"));
380394
DBUG_RETURN(false);
381395
}
382396

383397
// Setup transporter (transporter responsible for closing sockfd)
384-
bool res = t->connect_server(sockfd);
398+
bool res = t->connect_server(sockfd, msg);
385399

386400
if (res && performStates[nodeId] != TransporterRegistry::CONNECTING)
387401
{
402+
msg.assfmt("line: %u : Incorrect state for node %u state: %s (%u)",
403+
__LINE__, nodeId,
404+
getPerformStateString(performStates[nodeId]),
405+
performStates[nodeId]);
388406
// Connection suceeded, but not connecting anymore, return
389407
// false to close the connection
390408
DBUG_RETURN(false);

storage/ndb/src/mgmsrv/MgmtSrvr.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -3763,11 +3763,12 @@ MgmtSrvr::getConnectionDbParameter(int node1, int node2,
37633763
}
37643764

37653765

3766-
bool MgmtSrvr::transporter_connect(NDB_SOCKET_TYPE sockfd)
3766+
bool
3767+
MgmtSrvr::transporter_connect(NDB_SOCKET_TYPE sockfd, BaseString& msg)
37673768
{
37683769
DBUG_ENTER("MgmtSrvr::transporter_connect");
37693770
TransporterRegistry* tr= theFacade->get_registry();
3770-
if (!tr->connect_server(sockfd))
3771+
if (!tr->connect_server(sockfd, msg))
37713772
DBUG_RETURN(false);
37723773

37733774
/*

storage/ndb/src/mgmsrv/MgmtSrvr.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ class MgmtSrvr : private ConfigSubscriber, public trp_client {
345345
int getConnectionDbParameter(int node1, int node2, int param,
346346
int *value, BaseString& msg);
347347

348-
bool transporter_connect(NDB_SOCKET_TYPE sockfd);
348+
bool transporter_connect(NDB_SOCKET_TYPE sockfd, BaseString& errormsg);
349349

350350
const char *get_connect_address(Uint32 node_id);
351351
void get_connected_nodes(NodeBitmask &connected_nodes) const;

storage/ndb/src/mgmsrv/Services.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -1786,13 +1786,14 @@ void
17861786
MgmApiSession::transporter_connect(Parser_t::Context &ctx,
17871787
Properties const &args)
17881788
{
1789-
if (!m_mgmsrv.transporter_connect(m_socket))
1789+
BaseString errormsg;
1790+
if (!m_mgmsrv.transporter_connect(m_socket, errormsg))
17901791
{
17911792
// Connection not allowed or failed
17921793
g_eventLogger->warning("Failed to convert connection "
1793-
"from '%s' to transporter",
1794-
name());
1795-
1794+
"from '%s' to transporter: %s",
1795+
name(),
1796+
errormsg.c_str());
17961797
// Close the socket to indicate failure to other side
17971798
}
17981799
else

0 commit comments

Comments
 (0)