fix: do not exit in is_standby()

Instead we now return an int with 0 meaning „not a standby,“ 1 meaning
„is a standby“ and -1 meaning „connection dropped“
This commit is contained in:
Christian Kruse
2014-01-10 17:11:16 +01:00
parent c41030b40e
commit 4fabfbbbd0
4 changed files with 62 additions and 33 deletions

View File

@@ -165,7 +165,7 @@ main(int argc, char **argv)
};
int optindex;
int c;
int c, ret;
bool daemonize = false;
char standby_version[MAXVERSIONSTR];
@@ -301,14 +301,21 @@ 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))
myLocalMode = WITNESS_MODE;
else if (is_standby(myLocalConn))
else if (ret == 1)
myLocalMode = STANDBY_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)
exit(1);
else /* is the master */
myLocalMode = PRIMARY_MODE;