Skip to content

Commit

Permalink
Change the is_pgup () check test
Browse files Browse the repository at this point in the history
remove spurious 'return'
  • Loading branch information
Cédric Villemain authored and Jaime Casanova committed Mar 13, 2011
1 parent 7e58e6a commit 7df2fb7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
16 changes: 8 additions & 8 deletions dbutils.c
Expand Up @@ -131,7 +131,14 @@ is_pgup(PGconn *conn)
/* Check the connection status twice in case it changes after reset */
for (;;)
{
if (PQstatus(conn) == CONNECTION_OK)
if (PQstatus(conn) != CONNECTION_OK)
{
if (twice)
return false;
PQreset(conn); // reconnect
twice = true;
}
else
{
/*
* Send a SELECT 1 just to check if connection is OK
Expand All @@ -158,13 +165,6 @@ is_pgup(PGconn *conn)
return true;
}
}
else
{
if (twice)
return false;
PQreset(conn); // reconnect
twice = true;
}
}
}

Expand Down
14 changes: 2 additions & 12 deletions repmgrd.c
Expand Up @@ -305,7 +305,7 @@ WitnessMonitor(void)
* Check if the master is still available, if after 5 minutes of retries
* we cannot reconnect, return false.
*/
return CheckPrimaryConnection(); // this take up to NUM_RETRY * SLEEP_RETRY seconds
CheckPrimaryConnection(); // this take up to NUM_RETRY * SLEEP_RETRY seconds
}
/*
* Insert monitor info, this is basically the time and xlog replayed,
Expand Down Expand Up @@ -651,17 +651,7 @@ CheckPrimaryConnection(void)
{
log_err(_("\n%s: We couldn't reconnect for long enough, exiting...\n", progname));
/* XXX Anything else to do here? */
exit(ERR_BAD_CON);
}

/* Send a SELECT 1 just to check if connection is OK */
sprintf(sqlquery, "SELECT 1");
res = PQexec(primaryConn, sqlquery);
if (PQresultStatus(res) != PGRES_TUPLES_OK)
{
log_err(_("PQexec failed: %s\n", PQerrorMessage(primaryConn)));
PQclear(res);
return;
return false;
}
return true;
}
Expand Down

0 comments on commit 7df2fb7

Please sign in to comment.