Commit c4dd23f7 authored by unknown's avatar unknown

[PATCH] WL#3704 mgmapi timeouts: Correct cpc client usage of Socket Input/OutputStream for timeouts

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


storage/ndb/include/util/InputStream.hpp:
  WL#3704 mgmapi timeouts: Correct cpc client usage of Socket Input/OutputStream for timeouts
storage/ndb/test/include/CpcClient.hpp:
  WL#3704 mgmapi timeouts: Correct cpc client usage of Socket Input/OutputStream for timeouts
storage/ndb/test/src/CpcClient.cpp:
  WL#3704 mgmapi timeouts: Correct cpc client usage of Socket Input/OutputStream for timeouts
parent 5c529b66
......@@ -53,7 +53,7 @@ class SocketInputStream : public InputStream {
bool m_startover;
bool m_timedout;
public:
SocketInputStream(NDB_SOCKET_TYPE socket, unsigned read_timeout_ms = 1000);
SocketInputStream(NDB_SOCKET_TYPE socket, unsigned read_timeout_ms = 60000);
virtual ~SocketInputStream() {}
char* gets(char * buf, int bufLen);
bool timedout() { return m_timedout; };
......
......@@ -70,8 +70,6 @@ private:
char *host;
int port;
NDB_SOCKET_TYPE cpc_sock;
InputStream *cpc_in;
OutputStream *cpc_out;
public:
int connect();
......
......@@ -428,8 +428,6 @@ SimpleCpcClient::SimpleCpcClient(const char *_host, int _port) {
host = strdup(_host);
port = _port;
cpc_sock = -1;
cpc_in = NULL;
cpc_out = NULL;
}
SimpleCpcClient::~SimpleCpcClient() {
......@@ -444,12 +442,6 @@ SimpleCpcClient::~SimpleCpcClient() {
close(cpc_sock);
cpc_sock = -1;
}
if(cpc_in != NULL)
delete cpc_in;
if(cpc_out != NULL)
delete cpc_out;
}
int
......@@ -475,17 +467,15 @@ SimpleCpcClient::connect() {
if (::connect(cpc_sock, (struct sockaddr*) &sa, sizeof(sa)) < 0)
return -1;
cpc_in = new SocketInputStream(cpc_sock, 60000);
cpc_out = new SocketOutputStream(cpc_sock);
return 0;
}
int
SimpleCpcClient::cpc_send(const char *cmd,
const Properties &args) {
SocketOutputStream cpc_out(cpc_sock);
cpc_out->println(cmd);
cpc_out.println(cmd);
Properties::Iterator iter(&args);
const char *name;
......@@ -498,18 +488,18 @@ SimpleCpcClient::cpc_send(const char *cmd,
switch(t) {
case PropertiesType_Uint32:
args.get(name, &val_i);
cpc_out->println("%s: %d", name, val_i);
cpc_out.println("%s: %d", name, val_i);
break;
case PropertiesType_char:
args.get(name, val_s);
cpc_out->println("%s: %s", name, val_s.c_str());
cpc_out.println("%s: %s", name, val_s.c_str());
break;
default:
/* Silently ignore */
break;
}
}
cpc_out->println("");
cpc_out.println("");
return 0;
}
......@@ -523,9 +513,11 @@ SimpleCpcClient::Parser_t::ParserStatus
SimpleCpcClient::cpc_recv(const ParserRow_t *syntax,
const Properties **reply,
void **user_value) {
SocketInputStream cpc_in(cpc_sock);
Parser_t::Context ctx;
ParserDummy session(cpc_sock);
Parser_t parser(syntax, *cpc_in, true, true, true);
Parser_t parser(syntax, cpc_in, true, true, true);
*reply = parser.parse(ctx, session);
if(user_value != NULL)
*user_value = ctx.m_currentCmd->user_value;
......
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