PQconsumeinput() may close the fd

From: Vasily Kulikov <segoon(at)yandex-team(dot)ru>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: PQconsumeinput() may close the fd
Date: 2022-10-21 04:27:48
Message-ID: 53811666325878@mail.yandex-team.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

<div>Hello,</div><div> </div><div>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 beforehand. The core issue is that I have to deregister socket fd in the event loop, but the fd is already closed. It is already not good because we're still working with already invalid fd, but worse, in multithreaded env other thread might open a socket with the same fd number and mess all the things.</div><div> </div><div>So, what to do in this case? Should I use other API that may not close fd? Or only select/poll API may be used with every time fd registration, but not epoll? Or maybe I'm wrong in some other way?</div><div> </div><div>Thanks in advance.</div>

Attachment Content-Type Size
unknown_filename text/html 898 bytes

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Matthias Apitz 2022-10-21 07:48:02 Re: Mysterious performance degradation in exceptional cases
Previous Message Thomas Guyot 2022-10-21 03:25:37 Re: High CPU usage