From 92e99ddfb7f67f5ef4a4a6e9b3e8632672cb95cf Mon Sep 17 00:00:00 2001 From: MassimilianoPinto Date: Wed, 18 Feb 2015 11:04:50 +0100 Subject: [PATCH] Auto set router->masterid from master server-id MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Automatically set router->masterid if not specified in the option: it’s taken from master server-id --- server/modules/routing/binlog/blr_master.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/server/modules/routing/binlog/blr_master.c b/server/modules/routing/binlog/blr_master.c index cb0da38e3..7bd194ac6 100644 --- a/server/modules/routing/binlog/blr_master.c +++ b/server/modules/routing/binlog/blr_master.c @@ -387,14 +387,19 @@ char query[128]; break; case BLRM_SERVERID: { - char *val = blr_extract_column(buf, 1); + char *val = blr_extract_column(buf, 2); // Response to fetch of master's server-id if (router->saved_master.server_id) GWBUF_CONSUME_ALL(router->saved_master.server_id); router->saved_master.server_id = buf; blr_cache_response(router, "serverid", buf); - // TODO: Extract the value of server-id and place in router->master_id + + // set router->masterid from master server-id if it's not set by the config option + if (router->masterid == 0) { + router->masterid = atoi(val); + } + { char str[80]; sprintf(str, "SET @master_heartbeat_period = %lu000000000", router->heartbeat);