From ae28f8189b94e69dbbef30fa02ea754f3520f8f0 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Mon, 3 Sep 2018 10:10:03 +0300 Subject: [PATCH] MXS-2011 Change return value of blr_check_connect_retry 0 cannot be used to indicate failure as 0 will be the waiting period if we switch to an alternative server. Also fix some minor issues; failure to initialize all members and inverted success-check. --- server/modules/routing/binlogrouter/blr.hh | 2 ++ server/modules/routing/binlogrouter/blr_file.cc | 2 +- server/modules/routing/binlogrouter/blr_master.cc | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/server/modules/routing/binlogrouter/blr.hh b/server/modules/routing/binlogrouter/blr.hh index ff100ec0f..c31ac5496 100644 --- a/server/modules/routing/binlogrouter/blr.hh +++ b/server/modules/routing/binlogrouter/blr.hh @@ -378,6 +378,8 @@ public: ChangeMasterConfig(const char* name) : connection_name(name) + , port(-1) + , ssl_enabled(false) , heartbeat_period(BLR_HEARTBEAT_DEFAULT_INTERVAL_VALUE) , connect_retry(BLR_MASTER_CONNECT_RETRY_VALUE) { diff --git a/server/modules/routing/binlogrouter/blr_file.cc b/server/modules/routing/binlogrouter/blr_file.cc index bb27b185f..500f15d02 100644 --- a/server/modules/routing/binlogrouter/blr_file.cc +++ b/server/modules/routing/binlogrouter/blr_file.cc @@ -3331,7 +3331,7 @@ int blr_file_read_master_config(ROUTER_INSTANCE *router) int rc = ini_parse(filename, blr_handler_config, router); - if (rc == 1) + if (rc == 0) { mxb_assert(router->configs.size() > 0); blr_master_set_config(router, router->configs[0]); diff --git a/server/modules/routing/binlogrouter/blr_master.cc b/server/modules/routing/binlogrouter/blr_master.cc index b526588a4..f2baef686 100644 --- a/server/modules/routing/binlogrouter/blr_master.cc +++ b/server/modules/routing/binlogrouter/blr_master.cc @@ -163,7 +163,7 @@ static void blr_start_master(void* data) /* Check whether master connection can be started */ int connect_retry; - if ((connect_retry = blr_check_connect_retry(router)) == 0) + if ((connect_retry = blr_check_connect_retry(router)) == -1) { /* Force stopped state */ router->master_state = BLRM_SLAVE_STOPPED; @@ -359,7 +359,7 @@ blr_restart_master(ROUTER_INSTANCE *router) if (router->master_state < BLRM_BINLOGDUMP) { int connect_retry; - if ((connect_retry = blr_check_connect_retry(router)) == 0) + if ((connect_retry = blr_check_connect_retry(router)) == -1) { /* Force stopped state */ router->master_state = BLRM_SLAVE_STOPPED; @@ -3091,7 +3091,7 @@ static int blr_check_connect_retry(ROUTER_INSTANCE *router) /* Stop reconnection to master */ if (router->retry_count >= router->retry_limit) { - return 0; + return -1; } /* Return the interval for next reconnect */