pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Laurenz Albe <laurenz.albe@cybertec.at>
Cc: Vasily Kulikov <segoon@yandex-team.ru>
Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: PQconsumeinput() may close the fd
Date: Fri, 21 Oct 2022 10:40:28 -0400
Message-ID: <3198034.1666363228@sss.pgh.pa.us> (raw)
In-Reply-To: <7e60d1a4a536a12fdd1c15caae93bac79b0ab8b1.camel@cybertec.at>
References: <53811666325878@mail.yandex-team.ru>
	<7e60d1a4a536a12fdd1c15caae93bac79b0ab8b1.camel@cybertec.at>

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





view thread (4+ messages)  latest in thread

Message-ID: <3198034.1666363228@sss.pgh.pa.us>
Permalink:  ../3198034.1666363228@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3198034.1666363228@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, laurenz.albe@cybertec.at, segoon@yandex-team.ru
  Subject: Re: PQconsumeinput() may close the fd
  In-Reply-To: <3198034.1666363228@sss.pgh.pa.us>
  References: <53811666325878@mail.yandex-team.ru> <7e60d1a4a536a12fdd1c15caae93bac79b0ab8b1.camel@cybertec.at> <3198034.1666363228@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox