Added master_host update in the loop

Added master_host update in the loop, returns the right server in case
of multiple servers with same replication depth
This commit is contained in:
MassimilianoPinto
2014-06-25 15:51:29 +02:00
parent c14700fcff
commit 2eafe15bca

View File

@ -348,8 +348,10 @@ BACKEND *master_host = NULL;
int found = 0; int found = 0;
for (i = 0; inst->servers[i]; i++) { for (i = 0; inst->servers[i]; i++) {
if (inst->servers[i] && SERVER_IS_RUNNING(inst->servers[i]->server) && (inst->servers[i]->server->depth == master_host->server->depth)) { if (inst->servers[i] && SERVER_IS_RUNNING(inst->servers[i]->server) && (inst->servers[i]->server->depth == master_host->server->depth)) {
if (inst->servers[i]->server->status & SERVER_MASTER) if (inst->servers[i]->server->status & SERVER_MASTER) {
master_host = inst->servers[i];
found = 1; found = 1;
}
} }
} }
if (!found) if (!found)