Skip to content

Commit 3458707

Browse files
authored
Merge pull request #2 from usernamedt/fix-hanging-read
Fix hanging zpq_read
2 parents 0b55460 + d101f1e commit 3458707

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/interfaces/libpq/fe-exec.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1810,8 +1810,8 @@ PQgetResult(PGconn *conn)
18101810
* EOF indication. We expect therefore that this won't result in any
18111811
* undue delay in reporting a previous write failure.)
18121812
*/
1813-
if (flushResult ||
1814-
pqWait(true, false, conn) ||
1813+
if (flushResult || (zpq_buffered_rx(conn->zstream) == 0 &&
1814+
pqWait(true, false, conn)) ||
18151815
pqReadData(conn) < 0)
18161816
{
18171817
/*

src/interfaces/libpq/fe-protocol3.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,7 +1679,7 @@ pqGetCopyData3(PGconn *conn, char **buffer, int async)
16791679
if (async)
16801680
return 0;
16811681
/* Need to load more data */
1682-
if (pqWait(true, false, conn) ||
1682+
if ((zpq_buffered_rx(conn->zstream) == 0 && pqWait(true, false, conn)) ||
16831683
pqReadData(conn) < 0)
16841684
return -2;
16851685
continue;
@@ -1737,7 +1737,7 @@ pqGetline3(PGconn *conn, char *s, int maxlen)
17371737
while ((status = PQgetlineAsync(conn, s, maxlen - 1)) == 0)
17381738
{
17391739
/* need to load more data */
1740-
if (pqWait(true, false, conn) ||
1740+
if ((zpq_buffered_rx(conn->zstream) == 0 && pqWait(true, false, conn)) ||
17411741
pqReadData(conn) < 0)
17421742
{
17431743
*s = '\0';
@@ -1975,7 +1975,7 @@ pqFunctionCall3(PGconn *conn, Oid fnid,
19751975
if (needInput)
19761976
{
19771977
/* Wait for some data to arrive (or for the channel to close) */
1978-
if (pqWait(true, false, conn) ||
1978+
if ((zpq_buffered_rx(conn->zstream) == 0 && pqWait(true, false, conn)) ||
19791979
pqReadData(conn) < 0)
19801980
break;
19811981
}

0 commit comments

Comments
 (0)