summaryrefslogtreecommitdiff
path: root/server-tools/instance-manager/protocol.cc
diff options
context:
space:
mode:
authorunknown <petr@mysql.com>2005-04-09 14:28:39 +0400
committerunknown <petr@mysql.com>2005-04-09 14:28:39 +0400
commit76164b89d13331a01d5e5d03b09d3ecaf1a405c3 (patch)
treef1c7b9a70981085aed9d00273b9b8a0dfaafa37e /server-tools/instance-manager/protocol.cc
parent7ff83a3f7f520feda32fb5cf68da54771542cc80 (diff)
downloadmariadb-git-76164b89d13331a01d5e5d03b09d3ecaf1a405c3.tar.gz
WL#2246 "IM: Add ability to change instance options, add server logs handling" ported to the
current version of the IM server-tools/instance-manager/commands.cc: Log and set options commands added server-tools/instance-manager/commands.h: Log and set options commands added server-tools/instance-manager/factory.cc: Log and set options factory entries added server-tools/instance-manager/factory.h: prototypes added server-tools/instance-manager/instance_options.cc: fill_log_options() added server-tools/instance-manager/instance_options.h: log processing options and funcctions added server-tools/instance-manager/messages.cc: new error messages added (log and option processing-related) server-tools/instance-manager/mysql_connection.cc: minor fixes server-tools/instance-manager/mysql_manager_error.h: new error codes added server-tools/instance-manager/parse.cc: parser fixed to recognize new commands. function to parse command-line options added server-tools/instance-manager/parse.h: header fixed in line with .cc changes server-tools/instance-manager/parse_output.cc: cleanup server-tools/instance-manager/parse_output.h: header guards added server-tools/instance-manager/protocol.cc: Protocol support extended to provide messages in ok packet server-tools/instance-manager/protocol.h: protocol support extended: ok packet could contain messages
Diffstat (limited to 'server-tools/instance-manager/protocol.cc')
-rw-r--r--server-tools/instance-manager/protocol.cc53
1 files changed, 40 insertions, 13 deletions
diff --git a/server-tools/instance-manager/protocol.cc b/server-tools/instance-manager/protocol.cc
index 9c8975a78be..f0928743716 100644
--- a/server-tools/instance-manager/protocol.cc
+++ b/server-tools/instance-manager/protocol.cc
@@ -24,15 +24,25 @@
static char eof_buff[1]= { (char) 254 }; /* Marker for end of fields */
-int net_send_ok(struct st_net *net, unsigned long connection_id)
+
+int net_send_ok(struct st_net *net, unsigned long connection_id,
+ const char *message)
{
- char buff[1 + // packet type code
- 9 + // affected rows count
- 9 + // connection id
- 2 + // thread return status
- 2]; // warning count
+ /*
+ The format of a packet
+ 1 packet type code
+ 1-9 affected rows count
+ 1-9 connection id
+ 2 thread return status
+ 2 warning count
+ 1-9 + message length message to send (isn't stored if no message)
+ */
+ Buffer buff;
+ char *pos= buff.buffer;
+
+ /* check that we have space to hold mandatory fields */
+ buff.reserve(0, 23);
- char *pos= buff;
enum { OK_PACKET_CODE= 0 };
*pos++= OK_PACKET_CODE;
pos= net_store_length(pos, (ulonglong) 0);
@@ -43,7 +53,15 @@ int net_send_ok(struct st_net *net, unsigned long connection_id)
int2store(pos, 0);
pos+= 2;
- return my_net_write(net, buff, pos - buff) || net_flush(net);
+ uint position= pos - buff.buffer; /* we might need it for message */
+
+ if (message != NULL)
+ {
+ buff.reserve(position, 9 + strlen(message));
+ store_to_string(&buff, message, &position);
+ }
+
+ return my_net_write(net, buff.buffer, position) || net_flush(net);
}
@@ -99,15 +117,15 @@ char *net_store_length(char *pkg, uint length)
}
-int store_to_string(Buffer *buf, const char *string, uint *position)
+int store_to_string(Buffer *buf, const char *string, uint *position,
+ uint string_len)
{
uint currpos;
- uint string_len;
- string_len= strlen(string);
- if (buf->reserve(*position, 2))
+ if (buf->reserve(*position, 9))
goto err;
- currpos= (net_store_length(buf->buffer + *position, string_len) - buf->buffer);
+ currpos= (net_store_length(buf->buffer + *position,
+ (ulonglong) string_len) - buf->buffer);
if (buf->append(currpos, string, string_len))
goto err;
*position= *position + string_len + (currpos - *position);
@@ -118,6 +136,15 @@ err:
}
+int store_to_string(Buffer *buf, const char *string, uint *position)
+{
+ uint string_len;
+
+ string_len= strlen(string);
+ return store_to_string(buf, string, position, string_len);
+}
+
+
int send_eof(struct st_net *net)
{
char buff[1 + /* eof packet code */