Re: PQconsumeinput() may close the fd

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Cc: Vasily Kulikov <segoon(at)yandex-team(dot)ru>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: PQconsumeinput() may close the fd
Date: 2022-10-21 14:40:28
Message-ID: 3198034.1666363228@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dionisis Kontominas 2022-10-21 17:13:20 Asking for existence of a GUI frame work similar to Oracle APEX for PostgreSQL
Previous Message Laurenz Albe 2022-10-21 14:18:59 Re: PQconsumeinput() may close the fd