From c3aa5beeb45abc921bdc49a751e20269bea394ac Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Sun, 21 Jun 2015 19:32:19 +0300 Subject: [PATCH 1/3] Added missing initialization from MM monitor. --- server/modules/monitor/mmmon.c | 1 + 1 file changed, 1 insertion(+) diff --git a/server/modules/monitor/mmmon.c b/server/modules/monitor/mmmon.c index c0d54595d..545a77ca2 100644 --- a/server/modules/monitor/mmmon.c +++ b/server/modules/monitor/mmmon.c @@ -126,6 +126,7 @@ startMonitor(void *arg,void* opt) handle->shutdown = 0; handle->id = MONITOR_DEFAULT_ID; handle->master = NULL; + handle->script = NULL; memset(handle->events,false,sizeof(handle->events)); spinlock_init(&handle->lock); } From 8c900e73deab80691e004ee3319981adf173dd4e Mon Sep 17 00:00:00 2001 From: MassimilianoPinto Date: Mon, 22 Jun 2015 10:46:00 +0200 Subject: [PATCH 2/3] removed extra blr_file_add_magic removed extra blr_file_add_magic --- server/modules/include/blr.h | 1 + server/modules/routing/binlog/blr_file.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/server/modules/include/blr.h b/server/modules/include/blr.h index 62cda59a3..72171b253 100644 --- a/server/modules/include/blr.h +++ b/server/modules/include/blr.h @@ -34,6 +34,7 @@ #include #include +#include #define BINLOG_FNAMELEN 16 #define BLR_PROTOCOL "MySQLBackend" diff --git a/server/modules/routing/binlog/blr_file.c b/server/modules/routing/binlog/blr_file.c index ca92d6d06..68f47b1c3 100644 --- a/server/modules/routing/binlog/blr_file.c +++ b/server/modules/routing/binlog/blr_file.c @@ -210,9 +210,8 @@ int fd; close(router->binlog_fd); spinlock_acquire(&router->binlog_lock); strncpy(router->binlog_name, file,BINLOG_FNAMELEN); - blr_file_add_magic(router, fd); - spinlock_release(&router->binlog_lock); router->binlog_fd = fd; + spinlock_release(&router->binlog_lock); return 1; } @@ -254,12 +253,13 @@ int fd; LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, "%s: binlog file %s has an invalid length %d.", router->service->name, path, router->binlog_position))); - close(fd); + close(fd); + spinlock_release(&router->binlog_lock); return; } } - spinlock_release(&router->binlog_lock); router->binlog_fd = fd; + spinlock_release(&router->binlog_lock); } /** From 15e6d6f9fcb53eb0d95bb3a4e6e082815e72f2ec Mon Sep 17 00:00:00 2001 From: MassimilianoPinto Date: Mon, 22 Jun 2015 18:24:39 +0200 Subject: [PATCH 3/3] fix for missing crc check in blr_slave_fake_rotate() fix for missing crc check in blr_slave_fake_rotate() --- server/modules/routing/binlog/blr_slave.c | 27 ++++++++++++++--------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/server/modules/routing/binlog/blr_slave.c b/server/modules/routing/binlog/blr_slave.c index 4de69b8d7..ee7d52099 100644 --- a/server/modules/routing/binlog/blr_slave.c +++ b/server/modules/routing/binlog/blr_slave.c @@ -1693,6 +1693,9 @@ uint32_t chksum; binlognamelen = strlen(slave->binlogfile); len = 19 + 8 + 4 + binlognamelen; + /* no slave crc, remove 4 bytes */ + if (slave->nocrc) + len -= 4; // Build a fake rotate event resp = gwbuf_alloc(len + 5); @@ -1711,17 +1714,19 @@ uint32_t chksum; memcpy(ptr, slave->binlogfile, binlognamelen); ptr += binlognamelen; - /* - * Now add the CRC to the fake binlog rotate event. - * - * The algorithm is first to compute the checksum of an empty buffer - * 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 - * 5 bytes of the message. We also do not include the 4 byte checksum itself. - */ - chksum = crc32(0L, NULL, 0); - chksum = crc32(chksum, GWBUF_DATA(resp) + 5, hdr.event_size - 4); - encode_value(ptr, chksum, 32); + if (!slave->nocrc) { + /* + * Now add the CRC to the fake binlog rotate event. + * + * The algorithm is first to compute the checksum of an empty buffer + * 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 + * 5 bytes of the message. We also do not include the 4 byte checksum itself. + */ + 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); return 1;