Re: PQconsumeinput() may close the fd

2022-11-01 Thread Vasily Kulikov
21.10.2022, 17:40, "Tom Lane" :Laurenz Albe writes: On Fri, 2022-10-21 at 07:27 +0300, Vasily Kulikov wrote: The problem is that sometimes PQconsumeInput() may close the connectionWhat I'd suggest doing is checking for PQstatus(conn) == CONNECTION_BAD,or else directly rec

Re: PQconsumeinput() may close the fd

2022-10-21 Thread Tom Lane
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 i

Re: PQconsumeinput() may close the fd

2022-10-21 Thread Laurenz Albe
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 connec

PQconsumeinput() may close the fd

2022-10-21 Thread Vasily Kulikov
Hello, There is an event loop in my program (libev) and I do PQconsumeInput() if there is something ready in the PG socket fd. The problem is that sometimes PQconsumeInput() may close the connection and I learn it by checking for PQsocket() afterwards only. AFAICS, there is no way to learn it befor