mirror of
https://github.com/MariaDB/server.git
synced 2025-08-29 00:08:14 +03: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:
@@ -53,7 +53,7 @@ class SocketInputStream : public InputStream {
|
|||||||
bool m_startover;
|
bool m_startover;
|
||||||
bool m_timedout;
|
bool m_timedout;
|
||||||
public:
|
public:
|
||||||
SocketInputStream(NDB_SOCKET_TYPE socket, unsigned read_timeout_ms = 1000);
|
SocketInputStream(NDB_SOCKET_TYPE socket, unsigned read_timeout_ms = 60000);
|
||||||
virtual ~SocketInputStream() {}
|
virtual ~SocketInputStream() {}
|
||||||
char* gets(char * buf, int bufLen);
|
char* gets(char * buf, int bufLen);
|
||||||
bool timedout() { return m_timedout; };
|
bool timedout() { return m_timedout; };
|
||||||
|
@@ -70,8 +70,6 @@ private:
|
|||||||
char *host;
|
char *host;
|
||||||
int port;
|
int port;
|
||||||
NDB_SOCKET_TYPE cpc_sock;
|
NDB_SOCKET_TYPE cpc_sock;
|
||||||
InputStream *cpc_in;
|
|
||||||
OutputStream *cpc_out;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int connect();
|
int connect();
|
||||||
|
@@ -428,8 +428,6 @@ SimpleCpcClient::SimpleCpcClient(const char *_host, int _port) {
|
|||||||
host = strdup(_host);
|
host = strdup(_host);
|
||||||
port = _port;
|
port = _port;
|
||||||
cpc_sock = -1;
|
cpc_sock = -1;
|
||||||
cpc_in = NULL;
|
|
||||||
cpc_out = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleCpcClient::~SimpleCpcClient() {
|
SimpleCpcClient::~SimpleCpcClient() {
|
||||||
@@ -444,12 +442,6 @@ SimpleCpcClient::~SimpleCpcClient() {
|
|||||||
close(cpc_sock);
|
close(cpc_sock);
|
||||||
cpc_sock = -1;
|
cpc_sock = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cpc_in != NULL)
|
|
||||||
delete cpc_in;
|
|
||||||
|
|
||||||
if(cpc_out != NULL)
|
|
||||||
delete cpc_out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -475,17 +467,15 @@ SimpleCpcClient::connect() {
|
|||||||
if (::connect(cpc_sock, (struct sockaddr*) &sa, sizeof(sa)) < 0)
|
if (::connect(cpc_sock, (struct sockaddr*) &sa, sizeof(sa)) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
cpc_in = new SocketInputStream(cpc_sock, 60000);
|
|
||||||
cpc_out = new SocketOutputStream(cpc_sock);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
SimpleCpcClient::cpc_send(const char *cmd,
|
SimpleCpcClient::cpc_send(const char *cmd,
|
||||||
const Properties &args) {
|
const Properties &args) {
|
||||||
|
SocketOutputStream cpc_out(cpc_sock);
|
||||||
cpc_out->println(cmd);
|
|
||||||
|
cpc_out.println(cmd);
|
||||||
|
|
||||||
Properties::Iterator iter(&args);
|
Properties::Iterator iter(&args);
|
||||||
const char *name;
|
const char *name;
|
||||||
@@ -498,18 +488,18 @@ SimpleCpcClient::cpc_send(const char *cmd,
|
|||||||
switch(t) {
|
switch(t) {
|
||||||
case PropertiesType_Uint32:
|
case PropertiesType_Uint32:
|
||||||
args.get(name, &val_i);
|
args.get(name, &val_i);
|
||||||
cpc_out->println("%s: %d", name, val_i);
|
cpc_out.println("%s: %d", name, val_i);
|
||||||
break;
|
break;
|
||||||
case PropertiesType_char:
|
case PropertiesType_char:
|
||||||
args.get(name, val_s);
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
/* Silently ignore */
|
/* Silently ignore */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cpc_out->println("");
|
cpc_out.println("");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -523,9 +513,11 @@ SimpleCpcClient::Parser_t::ParserStatus
|
|||||||
SimpleCpcClient::cpc_recv(const ParserRow_t *syntax,
|
SimpleCpcClient::cpc_recv(const ParserRow_t *syntax,
|
||||||
const Properties **reply,
|
const Properties **reply,
|
||||||
void **user_value) {
|
void **user_value) {
|
||||||
|
SocketInputStream cpc_in(cpc_sock);
|
||||||
|
|
||||||
Parser_t::Context ctx;
|
Parser_t::Context ctx;
|
||||||
ParserDummy session(cpc_sock);
|
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);
|
*reply = parser.parse(ctx, session);
|
||||||
if(user_value != NULL)
|
if(user_value != NULL)
|
||||||
*user_value = ctx.m_currentCmd->user_value;
|
*user_value = ctx.m_currentCmd->user_value;
|
||||||
|
Reference in New Issue
Block a user