Re: pgsql: Use latch instead of select() in walreceiver

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: Use latch instead of select() in walreceiver
Date: 2016-12-02 01:50:30
Message-ID: CAB7nPqRA_cO_r_PLmRvFUtpvrTUeeBooXst1+oDecTPmTckp5A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On Fri, Dec 2, 2016 at 10:29 AM, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
> Use latch instead of select() in walreceiver
>
> Replace use of poll()/select() by WaitLatchOrSocket(), which is more
> portable and flexible.
>
> Also change walreceiver to use its procLatch instead of a custom latch.
>
> From: Petr Jelinek <petr(at)2ndquadrant(dot)com>

+ ResetLatch(&MyProc->procLatch);
+ rc = WaitLatchOrSocket(&MyProc->procLatch,
+ WL_POSTMASTER_DEATH | WL_SOCKET_READABLE |
+ WL_LATCH_SET,
+ PQsocket(streamConn),
+ 0,
+ WAIT_EVENT_LIBPQWALRECEIVER_READ);
+ if (rc & WL_POSTMASTER_DEATH)
+ exit(1);
Hmm. We have always been very careful about not leaving immediately
from libpqwalreceiver.c which is an independent shared library so as
the WAL receiver can take cleanup actions. See here for more details:
https://www.postgresql.org/message-id/CAEepm=0hg_FX7kdUhosTpJ_kPsUZw6k-7nuQNy-dGAOaetn_tA@mail.gmail.com
--
Michael

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2016-12-02 02:59:44 Re: pgsql: Refactor libpqwalreceiver
Previous Message Peter Eisentraut 2016-12-02 01:29:49 pgsql: Use latch instead of select() in walreceiver

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2016-12-02 01:52:29 Re: PSQL commands: \quit_if, \quit_unless
Previous Message Peter Eisentraut 2016-12-02 01:45:34 Re: Broken SSL tests in master