From 59f71a0d0b56b2df48db4bf1738aece5551f7a47 Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Wed, 14 Jan 2015 18:45:22 +0100 Subject: 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 --- src/backend/utils/misc/timeout.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/backend/utils/misc/timeout.c') diff --git a/src/backend/utils/misc/timeout.c b/src/backend/utils/misc/timeout.c index 1dec4928af0..ce4bc13ec3b 100644 --- a/src/backend/utils/misc/timeout.c +++ b/src/backend/utils/misc/timeout.c @@ -284,11 +284,9 @@ handle_sig_alarm(SIGNAL_ARGS) /* * SIGALRM is always cause for waking anything waiting on the process - * latch. Cope with MyProc not being there, as the startup process also - * uses this signal handler. + * latch. */ - if (MyProc) - SetLatch(&MyProc->procLatch); + SetLatch(MyLatch); /* * Fire any pending timeouts, but only if we're enabled to do so. -- cgit v1.2.3