Use server weights when choosing the candidate master
With this change, if two master servers both have equal depths but different weights, the one with the higher weight is used. If the depths and weights are equal, the first master listed in the configuration is used.
This commit is contained in:
@ -1015,12 +1015,18 @@ static BACKEND *get_root_master(BACKEND **servers)
|
||||
{
|
||||
if (servers[i] && (servers[i]->server->status & (SERVER_MASTER | SERVER_MAINT)) == SERVER_MASTER)
|
||||
{
|
||||
if (master_host && servers[i]->server->depth < master_host->server->depth)
|
||||
if (master_host == NULL)
|
||||
{
|
||||
master_host = servers[i];
|
||||
}
|
||||
else if (master_host == NULL)
|
||||
else if (servers[i]->server->depth < master_host->server->depth ||
|
||||
(servers[i]->server->depth == master_host->server->depth &&
|
||||
servers[i]->weight > master_host->weight))
|
||||
{
|
||||
/**
|
||||
* This master has a lower depth than the candidate master or
|
||||
* the depths are equal but this master has a higher weight
|
||||
*/
|
||||
master_host = servers[i];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user