do not exit() in is_witness

This commit is contained in:
Christian Kruse
2014-01-16 13:59:48 +01:00
parent 91446bcf93
commit 18206b3a64
3 changed files with 22 additions and 17 deletions

View File

@@ -301,23 +301,31 @@ main(int argc, char **argv)
*/
do
{
ret = is_standby(myLocalConn);
/*
* Set my server mode, establish a connection to primary
* and start monitor
*/
if (is_witness(myLocalConn, repmgr_schema, local_options.cluster_name, local_options.node))
ret = is_witness(myLocalConn, repmgr_schema, local_options.cluster_name, local_options.node);
if (ret == 1)
myLocalMode = WITNESS_MODE;
else if (ret == 1)
myLocalMode = STANDBY_MODE;
else if (ret == 0)
{
ret = is_standby(myLocalConn);
if (ret == 1)
myLocalMode = STANDBY_MODE;
else if (ret == 0) /* is the master */
myLocalMode = PRIMARY_MODE;
}
/* XXX we did this before changing is_standby() to return int; we
* should not exit at this point, but for now we do until we have a
* better strategy */
else if (ret == -1)
if (ret == -1)
{
exit(1);
else /* is the master */
myLocalMode = PRIMARY_MODE;
}
switch (myLocalMode)
{