From 00caba00fcea96edb6c25258d66366bb6d7030ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Sun, 24 Apr 2016 06:56:31 +0000 Subject: [PATCH] Minor bug fixes on #544 and #545 --- lib/MySQL_HostGroups_Manager.cpp | 6 ++++++ lib/MySQL_Monitor.cpp | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/MySQL_HostGroups_Manager.cpp b/lib/MySQL_HostGroups_Manager.cpp index f573b9725..20eef1e04 100644 --- a/lib/MySQL_HostGroups_Manager.cpp +++ b/lib/MySQL_HostGroups_Manager.cpp @@ -689,6 +689,12 @@ MySrvC *MyHGC::get_random_MySrvC() { } } } + + if (New_sum==0) { + proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 7, "Returning MySrvC NULL because no backend ONLINE or with weight\n"); + return NULL; // if we reach here, we couldn't find any target + } + unsigned int k=rand()%New_sum; k++; New_sum=0; diff --git a/lib/MySQL_Monitor.cpp b/lib/MySQL_Monitor.cpp index 94748fbf4..6afb18283 100644 --- a/lib/MySQL_Monitor.cpp +++ b/lib/MySQL_Monitor.cpp @@ -1018,7 +1018,7 @@ __end_monitor_ping_loop: if (resultset) { if (resultset->rows_count) { // disable host - proxy_error("Server %s:%s missed %d heartbeats, shunning it and killing all the connections\n", addresses[j], atoi(ports[j]), max_failures); + proxy_error("Server %s:%s missed %d heartbeats, shunning it and killing all the connections\n", addresses[j], ports[j], max_failures); MyHGM->shun_and_killall(addresses[j],atoi(ports[j])); } delete resultset;