mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 11:01:52 +01:00
[PATCH] WL#3704 mgmapi timeouts: Correct cpc client usage of Socket Input/OutputStream for timeouts
Index: ndb-work/storage/ndb/include/util/InputStream.hpp ===================================================================
This commit is contained in:
parent
2d11a87978
commit
75cff8cd26
3 changed files with 10 additions and 20 deletions
|
@ -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) {
|
||||
|
||||
cpc_out->println(cmd);
|
||||
SocketOutputStream cpc_out(cpc_sock);
|
||||
|
||||
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;
|
||||
|
|
Loading…
Add table
Reference in a new issue