pgsql: Add a default local latch for use in signal handlers.

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Add a default local latch for use in signal handlers.
Date: 2015-01-14 17:53:13
Message-ID: E1YBS81-0001yI-TQ@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(dot)GD5423(at)alap3(dot)anarazel(dot)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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2015-01-14 20:18:12 pgsql: vacuumlo: Avoid unlikely memory leak.
Previous Message Tom Lane 2015-01-14 16:08:24 pgsql: Allow CFLAGS from configure's environment to override automatic