pgsql: Add a default local latch for use in signal handlers. - Mailing list pgsql-committers

From Andres Freund
Subject pgsql: Add a default local latch for use in signal handlers.
Date
Msg-id E1YBS81-0001yI-TQ@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Add a default local latch for use in signal handlers.

To do so, move InitializeLatchSupport() into the new common process
initialization functions, and add a new global variable MyLatch.

MyLatch is usable as soon InitPostmasterChild() has been called
(i.e. very early during startup). Initially it points to a process
local latch that exists in all processes. InitProcess/InitAuxiliaryProcess
then replaces that local latch with PGPROC->procLatch. During shutdown
the reverse happens.

This is primarily advantageous for two reasons: For one it simplifies
dealing with the shared process latch, especially in signal handlers,
because instead of having to check for MyProc, MyLatch can be used
unconditionally. For another, a later patch that makes FEs/BE
communication use latches, now can rely on the existence of a latch,
even before having gone through InitProcess.

Discussion: 20140927191243.GD5423@alap3.anarazel.de

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/59f71a0d0b56b2df48db4bf1738aece5551f7a47

Modified Files
--------------
src/backend/postmaster/autovacuum.c      |   13 ++++-----
src/backend/postmaster/bgworker.c        |    4 +--
src/backend/postmaster/bgwriter.c        |   12 ++++-----
src/backend/postmaster/checkpointer.c    |   13 ++++-----
src/backend/postmaster/pgarch.c          |   21 +++++----------
src/backend/postmaster/pgstat.c          |   19 +++++---------
src/backend/postmaster/syslogger.c       |   21 +++++----------
src/backend/postmaster/walwriter.c       |   10 +++----
src/backend/replication/syncrep.c        |    4 +--
src/backend/storage/ipc/procsignal.c     |    4 +--
src/backend/storage/ipc/shm_mq.c         |   12 ++++-----
src/backend/storage/lmgr/proc.c          |   42 +++++++++++++-----------------
src/backend/tcop/postgres.c              |   12 +++------
src/backend/utils/adt/misc.c             |    4 +--
src/backend/utils/init/globals.c         |    9 +++++++
src/backend/utils/init/miscinit.c        |   37 ++++++++++++++++++++++++++
src/backend/utils/misc/timeout.c         |    6 ++---
src/include/miscadmin.h                  |    4 +++
src/include/storage/latch.h              |    2 +-
src/test/modules/test_shm_mq/setup.c     |    4 +--
src/test/modules/test_shm_mq/test.c      |    4 +--
src/test/modules/test_shm_mq/worker.c    |    3 +--
src/test/modules/worker_spi/worker_spi.c |   10 +++----
23 files changed, 136 insertions(+), 134 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Allow CFLAGS from configure's environment to override automatic
Next
From: Robert Haas
Date:
Subject: pgsql: vacuumlo: Avoid unlikely memory leak.