From: Tom Lane Date: Sun, 28 Dec 2003 17:29:51 +0000 (+0000) Subject: Avoid infinite loop if connection is lost during PQexecStart() or X-Git-Url: http://waps.l3s.uni-hannover.de/gitweb/?a=commitdiff_plain;h=33f9dba8edb9be3d947e59299ce4885a47185bef;p=users%2Fbernd%2Fpostgres.git Avoid infinite loop if connection is lost during PQexecStart() or PQexecFinish(). Per report from Andreas Pflug. --- diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c index af553724c6..8b22d5ef8c 100644 --- a/src/interfaces/libpq/fe-exec.c +++ b/src/interfaces/libpq/fe-exec.c @@ -1234,6 +1234,9 @@ PQexecStart(PGconn *conn) return false; } } + /* check for loss of connection, too */ + if (conn->status == CONNECTION_BAD) + return false; } /* OK to send a command */ @@ -1256,6 +1259,8 @@ PQexecFinish(PGconn *conn) * * We have to stop if we see copy in/out, however. We will resume parsing * after application performs the data transfer. + * + * Also stop if the connection is lost (else we'll loop infinitely). */ lastResult = NULL; while ((result = PQgetResult(conn)) != NULL) @@ -1281,7 +1286,8 @@ PQexecFinish(PGconn *conn) } lastResult = result; if (result->resultStatus == PGRES_COPY_IN || - result->resultStatus == PGRES_COPY_OUT) + result->resultStatus == PGRES_COPY_OUT || + conn->status == CONNECTION_BAD) break; }