MXS-2271 Store monitored servers in a vector

The array is still a public member because it's used in several non-member functions.
This commit is contained in:
Esa Korhonen
2019-01-24 12:43:27 +02:00
parent 9083ea2d02
commit cef4e836bc
7 changed files with 81 additions and 148 deletions

View File

@ -322,7 +322,7 @@ void MMMonitor::post_tick()
/* Update server status from monitor pending status on that server*/
for (MXS_MONITORED_SERVER* ptr = m_monitor->monitored_servers; ptr; ptr = ptr->next)
for (MXS_MONITORED_SERVER* ptr : m_servers)
{
if (!ptr->server->is_in_maint())
{
@ -367,9 +367,7 @@ MXS_MONITORED_SERVER* MMMonitor::get_current_master()
Monitor* mon = m_monitor;
MXS_MONITORED_SERVER* ptr;
ptr = mon->monitored_servers;
while (ptr)
for (auto ptr : m_servers)
{
/* The server could be in SERVER_IN_MAINT
* that means SERVER_IS_RUNNING returns 0
@ -377,7 +375,6 @@ MXS_MONITORED_SERVER* MMMonitor::get_current_master()
*/
if (ptr->server->is_down())
{
ptr = ptr->next;
continue;
}
@ -385,8 +382,6 @@ MXS_MONITORED_SERVER* MMMonitor::get_current_master()
{
m_master = ptr;
}
ptr = ptr->next;
}