Add a check of the connection inside the CancelQuery() so it check

that before trying to cancel a query, which can block.
This commit is contained in:
Jaime Casanova
2012-06-26 11:29:02 -05:00
parent d58ea77798
commit cb740b68be
3 changed files with 8 additions and 8 deletions

View File

@@ -146,7 +146,7 @@ is_pgup(PGconn *conn, int timeout)
/*
* Send a SELECT 1 just to check if the connection is OK
*/
CancelQuery(conn);
CancelQuery(conn, timeout);
if (wait_connection_availability(conn, timeout) != 1)
goto failed;
@@ -430,11 +430,13 @@ wait_connection_availability(PGconn *conn, int timeout)
void
CancelQuery(PGconn *conn)
CancelQuery(PGconn *conn, int timeout)
{
char errbuf[ERRBUFF_SIZE];
PGcancel *pgcancel;
wait_connection_availability(conn, timeout);
pgcancel = PQgetCancel(conn);
if (!pgcancel || PQcancel(pgcancel, errbuf, ERRBUFF_SIZE) == 0)
@@ -442,5 +444,3 @@ CancelQuery(PGconn *conn)
PQfreeCancel(pgcancel);
}