]> granicus.if.org Git - postgresql/commit
Add a default local latch for use in signal handlers.
authorAndres Freund <andres@anarazel.de>
Wed, 14 Jan 2015 17:45:22 +0000 (18:45 +0100)
committerAndres Freund <andres@anarazel.de>
Wed, 14 Jan 2015 17:45:22 +0000 (18:45 +0100)
commit59f71a0d0b56b2df48db4bf1738aece5551f7a47
tree6023eb572eade66adb21ee0ae84fd6aa33e30ac9
parent85a2a8903f7e9151793308d0638621003aded5ae
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
23 files changed:
src/backend/postmaster/autovacuum.c
src/backend/postmaster/bgworker.c
src/backend/postmaster/bgwriter.c
src/backend/postmaster/checkpointer.c
src/backend/postmaster/pgarch.c
src/backend/postmaster/pgstat.c
src/backend/postmaster/syslogger.c
src/backend/postmaster/walwriter.c
src/backend/replication/syncrep.c
src/backend/storage/ipc/procsignal.c
src/backend/storage/ipc/shm_mq.c
src/backend/storage/lmgr/proc.c
src/backend/tcop/postgres.c
src/backend/utils/adt/misc.c
src/backend/utils/init/globals.c
src/backend/utils/init/miscinit.c
src/backend/utils/misc/timeout.c
src/include/miscadmin.h
src/include/storage/latch.h
src/test/modules/test_shm_mq/setup.c
src/test/modules/test_shm_mq/test.c
src/test/modules/test_shm_mq/worker.c
src/test/modules/worker_spi/worker_spi.c