Re: PQconsumeinput() may close the fd
Re: PQconsumeinput() may close the fd
От:
Laurenz Albe <laurenz.albe@cybertec.at>
Дата:
On Fri, 2022-10-21 at 07:27 +0300, Vasily Kulikov wrote: > The problem is that sometimes PQconsumeInput() may close the connection The function does nothing of the kind. Is there an error response from the function? Perhaps something else, like a timeout in a network component, closes the connections afterwards. Can you find any corresponding messages in the PostgreSQL server log? Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com
Re: PQconsumeinput() may close the fd
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Laurenz Albe writes: > On Fri, 2022-10-21 at 07:27 +0300, Vasily Kulikov wrote: >> The problem is that sometimes PQconsumeInput() may close the connection > The function does nothing of the kind. No, he's right: if we detect EOF then we'll close the socket. However, not doing so wouldn't be an improvement. I believe the socket would still be read-ready so you'd have an infinite loop. What I'd suggest doing is checking for PQstatus(conn) == CONNECTION_BAD, or else directly rechecking PQsocket() each time, rather than assuming the socket is still there. regards, tom lane