Re: PQconsumeinput() may close the fd - Mailing list pgsql-general

From Tom Lane
Subject Re: PQconsumeinput() may close the fd
Date
Msg-id 3198034.1666363228@sss.pgh.pa.us
Whole thread Raw
In response to Re: PQconsumeinput() may close the fd  (Laurenz Albe <laurenz.albe@cybertec.at>)
List pgsql-general
Laurenz Albe <laurenz.albe@cybertec.at> 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



pgsql-general by date:

Previous
From: Laurenz Albe
Date:
Subject: Re: PQconsumeinput() may close the fd
Next
From: Dionisis Kontominas
Date:
Subject: Asking for existence of a GUI frame work similar to Oracle APEX for PostgreSQL