]> granicus.if.org Git - postgresql/commit
Ensure we discard unread/unsent data when abandoning a connection attempt.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 27 Aug 2011 18:16:19 +0000 (14:16 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 27 Aug 2011 18:16:19 +0000 (14:16 -0400)
commitef3455f190d3c12de71c06316109bb5ffbffe462
treec9d953d095fb4fdb2c2b826eb23ba845e401a6b5
parent814a7f50c6c53883b0b753458c9912b0e6bc2519
Ensure we discard unread/unsent data when abandoning a connection attempt.

There are assorted situations wherein PQconnectPoll() will abandon a
connection attempt and try again with different parameters (eg, SSL versus
not SSL).  However, the code forgot to discard any pending data in libpq's
I/O buffers when doing this.  In at least one case (server returns E
message during SSL negotiation), there is unread input data which bollixes
the next connection attempt.  I have not checked to see whether this is
possible in the other cases where we close the socket and retry, but it
seems like a matter of good defensive programming to add explicit
buffer-flushing code to all of them.

This is one of several issues exposed by Daniel Farina's report of
misbehavior after a server-side fork failure.

This has been wrong since forever, so back-patch to all supported branches.
src/interfaces/libpq/fe-connect.c