Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1opnCo-0007dn-JP for pgsql-general@arkaria.postgresql.org; Tue, 01 Nov 2022 09:05:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1opnCn-0005le-HK for pgsql-general@arkaria.postgresql.org; Tue, 01 Nov 2022 09:05:09 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1opmLd-00009Y-Lq for pgsql-general@lists.postgresql.org; Tue, 01 Nov 2022 08:10:13 +0000 Received: from forwardcorp1b.mail.yandex.net ([178.154.239.136]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1opmLZ-0004Ib-Nh for pgsql-general@postgresql.org; Tue, 01 Nov 2022 08:10:12 +0000 Received: from sas2-6a1db1376cb6.qloud-c.yandex.net (sas2-6a1db1376cb6.qloud-c.yandex.net [IPv6:2a02:6b8:c08:bb0f:0:640:6a1d:b137]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTP id 49D5F60A45; Tue, 1 Nov 2022 11:09:45 +0300 (MSK) Received: from mail.yandex-team.ru (mail.yandex-team.ru [2a02:6b8:b081:b53e::1:c]) by sas2-6a1db1376cb6.qloud-c.yandex.net (mxbackcorp/Yandex) with HTTP id f9MjN50Kga61-9jK0OpKi; Tue, 01 Nov 2022 11:09:45 +0300 X-Yandex-Fwd: 2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1667290185; bh=MT7fzJE7HRT7o1RSR309dBjVY9B6Fc4dP/1VkmjnkZw=; h=References:Date:Message-Id:Cc:Subject:To:From:In-Reply-To; b=uh1ZaXG0SYtVprG+QDS6yS0YwhTnFjBduL+4FkXReyJraw99bKyyxFymG087EbYkN ykRoPvMTgHJjqcJIka4K1bZj4BwwUnCThZVWMj2jNYPaEWxVnmxrkxo3iqFwoH/qk8 UaArvdcVzi14LQbG44huIXBWLL6UgZ8IGQdvWgyg= Authentication-Results: sas2-6a1db1376cb6.qloud-c.yandex.net; dkim=pass header.i=@yandex-team.ru Received: from 3ahzf6w6bumkt4xv.vla.yp-c.yandex.net (3ahzf6w6bumkt4xv.vla.yp-c.yandex.net [2a02:6b8:c0d:2a92:0:640:da27:0]) by vla5-d6ec41cad181.qloud-c.yandex.net (mxbackcorp/Yandex) with HTTP id 49Mn750JOqM1-0ouY0qTz for ; Tue, 01 Nov 2022 11:09:35 +0300 Received: by 3ahzf6w6bumkt4xv.vla.yp-c.yandex.net with HTTP; Tue, 01 Nov 2022 11:09:34 +0300 From: Vasily Kulikov To: Tom Lane , Laurenz Albe Cc: "pgsql-general@postgresql.org" 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> Subject: Re: PQconsumeinput() may close the fd MIME-Version: 1.0 X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Tue, 01 Nov 2022 11:09:44 +0300 Message-Id: <255131667290089@mail.yandex-team.ru> Content-Transfer-Encoding: 8bit Content-Type: text/html; charset=utf-8 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk
21.10.2022, 17:40, "Tom Lane" <tgl@sss.pgh.pa.us>:

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

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.

I've chosen this one. Thanks for the help!