Auto set router->masterid from master server-id

Automatically set router->masterid if not specified in the option: it’s
taken from  master server-id
This commit is contained in:
MassimilianoPinto 2015-02-18 11:04:50 +01:00
parent 03456b931b
commit 92e99ddfb7

View File

@ -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);