From 601eac5a5dd2a73bfdd451326e730c1ca6dd4bb1 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Fri, 18 Sep 2015 17:20:50 +0300 Subject: [PATCH 1/3] Fixed parent-child code being called in non-daemon mode. --- server/core/gateway.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/core/gateway.c b/server/core/gateway.c index ed1a3d0d4..5c2355bee 100644 --- a/server/core/gateway.c +++ b/server/core/gateway.c @@ -2000,7 +2000,8 @@ int main(int argc, char **argv) * Successful start, notify the parent process that it can exit. */ ss_dassert(rc == MAXSCALE_SHUTDOWN); - write_child_exit_code(daemon_pipe[1], rc); + if(daemon_mode) + write_child_exit_code(daemon_pipe[1], rc); MaxScaleStarted = time(0); /*< From 2c12ba3d16a3d174500c1a32d8609bf7aec61b1e Mon Sep 17 00:00:00 2001 From: MassimilianoPinto Date: Mon, 21 Sep 2015 08:44:33 +0200 Subject: [PATCH 2/3] Various fixes Various fixes for initialisation and packet size allocation --- server/modules/routing/binlog/blr_file.c | 2 +- server/modules/routing/binlog/blr_slave.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/server/modules/routing/binlog/blr_file.c b/server/modules/routing/binlog/blr_file.c index 907c9397e..fa39aca02 100644 --- a/server/modules/routing/binlog/blr_file.c +++ b/server/modules/routing/binlog/blr_file.c @@ -334,7 +334,7 @@ BLFILE *file; return file; } - if ((file = (BLFILE *)malloc(sizeof(BLFILE))) == NULL) + if ((file = (BLFILE *)calloc(1, sizeof(BLFILE))) == NULL) { spinlock_release(&router->fileslock); return NULL; diff --git a/server/modules/routing/binlog/blr_slave.c b/server/modules/routing/binlog/blr_slave.c index 99d361afc..dd53eed7a 100644 --- a/server/modules/routing/binlog/blr_slave.c +++ b/server/modules/routing/binlog/blr_slave.c @@ -463,8 +463,9 @@ int query_len; "%s: Expected DISCONNECT SERVER $server_id", router->service->name))); } else { + int serverid = atoi(word); free(query_text); - return blr_slave_disconnect_server(router, slave, atoi(word)); + return blr_slave_disconnect_server(router, slave, serverid); } } } @@ -1075,7 +1076,7 @@ ROUTER_SLAVE *sptr; sprintf(port, "%d", sptr->port); sprintf(master_id, "%d", router->serverid); sprintf(slave_uuid, "%s", sptr->uuid ? sptr->uuid : ""); - len = 5 + strlen(server_id) + strlen(host) + strlen(port) + len = 4 + strlen(server_id) + strlen(host) + strlen(port) + strlen(master_id) + strlen(slave_uuid) + 5; if ((pkt = gwbuf_alloc(len)) == NULL) return 0; @@ -1907,7 +1908,7 @@ int len, id_len, seqno = 2; strcpy(state, "not found"); id_len = strlen(serverid); - len = 5 + id_len + strlen(state) + 1; + len = 4 + (1 + id_len) + (1 + strlen(state)); if ((pkt = gwbuf_alloc(len)) == NULL) return 0; @@ -1918,7 +1919,7 @@ int len, id_len, seqno = 2; blr_slave_send_eof(router, slave, seqno++); ptr = GWBUF_DATA(pkt); - encode_value(ptr, id_len + 2 + strlen(state), 24); // Add length of data packet + encode_value(ptr, len - 4), 24); // Add length of data packet ptr += 3; *ptr++ = seqno++; // Sequence number in response From de8e54da8b1fcd97a646efedd36eb5375c68028b Mon Sep 17 00:00:00 2001 From: MassimilianoPinto Date: Mon, 21 Sep 2015 08:52:39 +0200 Subject: [PATCH 3/3] Fix for compile error Fix for compile error --- server/modules/routing/binlog/blr_slave.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/modules/routing/binlog/blr_slave.c b/server/modules/routing/binlog/blr_slave.c index dd53eed7a..e92beb277 100644 --- a/server/modules/routing/binlog/blr_slave.c +++ b/server/modules/routing/binlog/blr_slave.c @@ -1919,7 +1919,7 @@ int len, id_len, seqno = 2; blr_slave_send_eof(router, slave, seqno++); ptr = GWBUF_DATA(pkt); - encode_value(ptr, len - 4), 24); // Add length of data packet + encode_value(ptr, len - 4, 24); // Add length of data packet ptr += 3; *ptr++ = seqno++; // Sequence number in response