From 75cff8cd263b5f3ff876cda9045f9b8ed73fb6c8 Mon Sep 17 00:00:00 2001 From: "stewart@mysql.com[stewart]" <> Date: Thu, 22 Mar 2007 22:35:55 +1100 Subject: [PATCH] [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 | 2 +- storage/ndb/test/include/CpcClient.hpp | 2 -- storage/ndb/test/src/CpcClient.cpp | 26 ++++++++---------------- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/storage/ndb/include/util/InputStream.hpp b/storage/ndb/include/util/InputStream.hpp index 2b0e6cfc5b9..746fb7904a4 100644 --- a/storage/ndb/include/util/InputStream.hpp +++ b/storage/ndb/include/util/InputStream.hpp @@ -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; }; diff --git a/storage/ndb/test/include/CpcClient.hpp b/storage/ndb/test/include/CpcClient.hpp index 62f016f8e1d..a743499566f 100644 --- a/storage/ndb/test/include/CpcClient.hpp +++ b/storage/ndb/test/include/CpcClient.hpp @@ -70,8 +70,6 @@ private: char *host; int port; NDB_SOCKET_TYPE cpc_sock; - InputStream *cpc_in; - OutputStream *cpc_out; public: int connect(); diff --git a/storage/ndb/test/src/CpcClient.cpp b/storage/ndb/test/src/CpcClient.cpp index 51f2fb4cf4d..d5dfd01327e 100644 --- a/storage/ndb/test/src/CpcClient.cpp +++ b/storage/ndb/test/src/CpcClient.cpp @@ -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;