fix for missing crc check in blr_slave_fake_rotate()

fix for missing crc check in blr_slave_fake_rotate()

fix for missing @@version_comment in order to allow mysql client get in
This commit is contained in:
MassimilianoPinto
2015-06-22 18:21:43 +02:00
parent 5bc07c5100
commit 2816d87013
2 changed files with 26 additions and 12 deletions

View File

@ -73,6 +73,9 @@
#define BLR_MASTER_BACKOFF_TIME 10 #define BLR_MASTER_BACKOFF_TIME 10
#define BLR_MAX_BACKOFF 60 #define BLR_MAX_BACKOFF 60
/* max size for error message returned to client */
#define BINLOG_ERROR_MSG_LEN 255
/** /**
* Some useful macros for examining the MySQL Response packets * Some useful macros for examining the MySQL Response packets
*/ */

View File

@ -271,7 +271,11 @@ int query_len;
else if (strcasecmp(word, "@@version_comment") == 0) else if (strcasecmp(word, "@@version_comment") == 0)
{ {
free(query_text); free(query_text);
return blr_slave_replay(router, slave, router->saved_master.selectvercom); if (!router->saved_master.selectvercom)
/* This will allow mysql client to get in when @@version_comment is not available */
return blr_slave_send_ok(router, slave);
else
return blr_slave_replay(router, slave, router->saved_master.selectvercom);
} }
else if (strcasecmp(word, "@@hostname") == 0) else if (strcasecmp(word, "@@hostname") == 0)
{ {
@ -1800,6 +1804,10 @@ uint32_t chksum;
binlognamelen = strlen(slave->binlogfile); binlognamelen = strlen(slave->binlogfile);
len = 19 + 8 + 4 + binlognamelen; len = 19 + 8 + 4 + binlognamelen;
/* no slave crc, remove 4 bytes */
if (slave->nocrc)
len -= 4;
// Build a fake rotate event // Build a fake rotate event
resp = gwbuf_alloc(len + 5); resp = gwbuf_alloc(len + 5);
hdr.payload_len = len + 1; hdr.payload_len = len + 1;
@ -1817,17 +1825,20 @@ uint32_t chksum;
memcpy(ptr, slave->binlogfile, binlognamelen); memcpy(ptr, slave->binlogfile, binlognamelen);
ptr += binlognamelen; ptr += binlognamelen;
/* /* if slave has crc add the chksum */
* Now add the CRC to the fake binlog rotate event. if (!slave->nocrc) {
* /*
* The algorithm is first to compute the checksum of an empty buffer * Now add the CRC to the fake binlog rotate event.
* and then the checksum of the event portion of the message, ie we do not *
* include the length, sequence number and ok byte that makes up the first * The algorithm is first to compute the checksum of an empty buffer
* 5 bytes of the message. We also do not include the 4 byte checksum itself. * and then the checksum of the event portion of the message, ie we do not
*/ * include the length, sequence number and ok byte that makes up the first
chksum = crc32(0L, NULL, 0); * 5 bytes of the message. We also do not include the 4 byte checksum itself.
chksum = crc32(chksum, GWBUF_DATA(resp) + 5, hdr.event_size - 4); */
encode_value(ptr, chksum, 32); chksum = crc32(0L, NULL, 0);
chksum = crc32(chksum, GWBUF_DATA(resp) + 5, hdr.event_size - 4);
encode_value(ptr, chksum, 32);
}
slave->dcb->func.write(slave->dcb, resp); slave->dcb->func.write(slave->dcb, resp);
return 1; return 1;