Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 2d337ad

Browse files
larskanisCommitfest Bot
authored and
Commitfest Bot
committed
libpq: Process buffered SSL read bytes to support records >8kB on async API
The async API of libpq doesn't support SSL record sizes >8kB so far. This size isn't exceeded by vanilla PostgreSQL, but by other products using the postgres wire protocol 3. PQconsumeInput() reads all data readable from the socket, so that the read condition is cleared. But it doesn't process all the data that is pending on the SSL layer. Also a subsequent call to PQisBusy() doesn't process it, so that the client is triggered to wait for more readable data on the socket. But this never arrives, so that the connection blocks infinitely. To fix this issue call pqReadData() repeatedly until there is no buffered SSL data left to be read. The synchronous libpq API isn't affected, since it supports arbitrary SSL record sizes already.
1 parent 03c53a7 commit 2d337ad

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/interfaces/libpq/fe-exec.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2006,6 +2006,19 @@ PQconsumeInput(PGconn *conn)
20062006
if (pqReadData(conn) < 0)
20072007
return 0;
20082008

2009+
#ifdef USE_SSL
2010+
/*
2011+
* Ensure all buffered read bytes in the SSL library are processed,
2012+
* which might be not the case, if the SSL record size exceeds 8k.
2013+
* Otherwise parseInput can't process the data.
2014+
*/
2015+
while (conn->ssl_in_use && pgtls_read_pending(conn))
2016+
{
2017+
if (pqReadData(conn) < 0)
2018+
return 0;
2019+
}
2020+
#endif
2021+
20092022
/* Parsing of the data waits till later. */
20102023
return 1;
20112024
}

0 commit comments

Comments
 (0)