Commit 8293b317 authored by unknown's avatar unknown

[PATCH] WL#3704 mgmapi timeouts: Add bool timeout flag to Streams

Index: ndb-work/storage/ndb/include/util/InputStream.hpp
===================================================================


storage/ndb/include/util/InputStream.hpp:
  WL#3704 mgmapi timeouts: Add bool timeout flag to Streams
storage/ndb/include/util/OutputStream.hpp:
  WL#3704 mgmapi timeouts: Add bool timeout flag to Streams
storage/ndb/src/common/util/InputStream.cpp:
  WL#3704 mgmapi timeouts: Add bool timeout flag to Streams
storage/ndb/src/common/util/OutputStream.cpp:
  WL#3704 mgmapi timeouts: Add bool timeout flag to Streams
storage/ndb/src/mgmsrv/Services.cpp:
  WL#3704 mgmapi timeouts: Add bool timeout flag to Streams
storage/ndb/test/ndbapi/testMgm.cpp:
  WL#3704 mgmapi timeouts: Add bool timeout flag to Streams
parent 45f698c5
......@@ -50,10 +50,14 @@ class SocketInputStream : public InputStream {
NDB_SOCKET_TYPE m_socket;
unsigned m_timeout_ms;
bool m_startover;
bool m_timedout;
public:
SocketInputStream(NDB_SOCKET_TYPE socket, unsigned read_timeout_ms = 1000);
virtual ~SocketInputStream() {}
char* gets(char * buf, int bufLen);
bool timedout() { return m_timedout; };
void reset_timeout() { m_timedout= false; };
};
#endif
......@@ -45,9 +45,12 @@ public:
class SocketOutputStream : public OutputStream {
NDB_SOCKET_TYPE m_socket;
unsigned m_timeout_ms;
bool m_timedout;
public:
SocketOutputStream(NDB_SOCKET_TYPE socket, unsigned write_timeout_ms = 1000);
virtual ~SocketOutputStream() {}
bool timedout() { return m_timedout; };
void reset_timeout() { m_timedout= false; };
int print(const char * fmt, ...);
int println(const char * fmt, ...);
......
......@@ -38,10 +38,13 @@ SocketInputStream::SocketInputStream(NDB_SOCKET_TYPE socket,
: m_socket(socket) {
m_startover= true;
m_timeout_ms = read_timeout_ms;
m_timedout= false;
}
char*
SocketInputStream::gets(char * buf, int bufLen) {
if(timedout())
return 0;
assert(bufLen >= 2);
int offset= 0;
if(m_startover)
......@@ -63,7 +66,10 @@ SocketInputStream::gets(char * buf, int bufLen) {
m_startover= true;
if(res == -1)
{
m_timedout= true;
return 0;
}
return buf;
}
......@@ -45,21 +45,38 @@ SocketOutputStream::SocketOutputStream(NDB_SOCKET_TYPE socket,
unsigned write_timeout_ms){
m_socket = socket;
m_timeout_ms = write_timeout_ms;
m_timedout= false;
}
int
SocketOutputStream::print(const char * fmt, ...){
va_list ap;
if(timedout())
return -1;
va_start(ap, fmt);
const int ret = vprint_socket(m_socket, m_timeout_ms, fmt, ap);
va_end(ap);
if (errno==ETIMEDOUT)
m_timedout= true;
return ret;
}
int
SocketOutputStream::println(const char * fmt, ...){
va_list ap;
if(timedout())
return -1;
va_start(ap, fmt);
const int ret = vprintln_socket(m_socket, m_timeout_ms, fmt, ap);
va_end(ap);
if (errno==ETIMEDOUT)
m_timedout= true;
return ret;
}
......@@ -1642,6 +1642,11 @@ MgmApiSession::get_mgmd_nodeid(Parser_t::Context &ctx,
{
m_output->println("get mgmd nodeid reply");
m_output->println("nodeid:%u",m_mgmsrv.getOwnNodeId());
if(ERROR_INSERTED(1))
{
NdbSleep_SecSleep(10);
}
m_output->println("");
}
......
......@@ -218,16 +218,12 @@ int runTestApiTimeout1(NDBT_Context* ctx, NDBT_Step* step)
ndb_mgm_set_connectstring(h, mgm);
ndb_mgm_connect(h,0,0,0);
ndbout << "Connected" << endl;
if(ndb_mgm_check_connection(h) < 0)
{
result= NDBT_FAILED;
goto done;
}
ndbout << "Checked Connection" << endl;
ndb_mgm_reply reply;
reply.return_code= 0;
......@@ -238,9 +234,7 @@ int runTestApiTimeout1(NDBT_Context* ctx, NDBT_Step* step)
goto done;
}
ndbout << "Inserted session error" << endl;
ndb_mgm_set_timeout(h,1000,1000);
ndb_mgm_set_timeout(h,2500);
cc= ndb_mgm_check_connection(h);
if(cc < 0)
......@@ -248,7 +242,29 @@ int runTestApiTimeout1(NDBT_Context* ctx, NDBT_Step* step)
else
result= NDBT_FAILED;
ndbout << "Tried check connection with result: " << cc << endl;
ndbout << "test 2" << endl;
ndb_mgm_connect(h,0,0,0);
cc= ndb_mgm_get_mgmd_nodeid(h);
if(cc==0)
result= NDBT_OK;
else
result= NDBT_FAILED;
if(ndb_mgm_insert_error(h, 3, 0, &reply)< 0)
{
ndbout << "failed to remove inserted error " << endl;
result= NDBT_FAILED;
goto done;
}
cc= ndb_mgm_get_mgmd_nodeid(h);
ndbout << "got node id: " << cc << endl;
if(cc==0)
result= NDBT_FAILED;
else
result= NDBT_OK;
done:
ndb_mgm_disconnect(h);
ndb_mgm_destroy_handle(&h);
......
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