Refactor if-statement

This commit is contained in:
Ian Barwick
2015-01-13 13:40:47 +09:00
parent b80d25ad33
commit 1a790549ea

View File

@@ -1154,8 +1154,16 @@ do_failover(void)
} }
} }
/* No candidate found */
if (!find_best)
{
log_err(_("%s: No suitable candidate for promotion found; terminating.\n"),
progname);
terminate(ERR_FAILOVER_FAIL);
}
/* once we know who is the best candidate, promote it */ /* once we know who is the best candidate, promote it */
if (find_best && (best_candidate.node_id == local_options.node)) if (best_candidate.node_id == local_options.node)
{ {
// ZZZ from loop above this should never happen anyway??? // ZZZ from loop above this should never happen anyway???
// in fact do_failover is never called if rempgrd is running on a witness, // in fact do_failover is never called if rempgrd is running on a witness,
@@ -1190,7 +1198,7 @@ do_failover(void)
terminate(ERR_BAD_CONFIG); terminate(ERR_BAD_CONFIG);
} }
} }
else if (find_best) else
{ {
/* wait */ /* wait */
sleep(10); sleep(10);
@@ -1217,12 +1225,6 @@ do_failover(void)
terminate(ERR_BAD_CONFIG); terminate(ERR_BAD_CONFIG);
} }
} }
else
{
log_err(_("%s: Did not find candidates. You should check and try manually.\n"),
progname);
terminate(ERR_FAILOVER_FAIL);
}
log_debug("failover done\n"); log_debug("failover done\n");
/* to force it to re-calculate mode and master node */ /* to force it to re-calculate mode and master node */