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[email protected]
* Wait until naptime expires or we get some type of signal (all the
* signal handlers will wake us by calling SetLatch).
*/
- rc = WaitLatch(&MyProc->procLatch,
+ rc = WaitLatch(MyLatch,
WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH,
(nap.tv_sec * 1000L) + (nap.tv_usec / 1000L));
- ResetLatch(&MyProc->procLatch);
+ ResetLatch(MyLatch);
DisableCatchupInterrupt();
int save_errno = errno;
got_SIGHUP = true;
- if (MyProc)
- SetLatch(&MyProc->procLatch);
+ SetLatch(MyLatch);
errno = save_errno;
}
int save_errno = errno;
got_SIGUSR2 = true;
- if (MyProc)
- SetLatch(&MyProc->procLatch);
+ SetLatch(MyLatch);
errno = save_errno;
}
int save_errno = errno;
got_SIGTERM = true;
- if (MyProc)
- SetLatch(&MyProc->procLatch);
+ SetLatch(MyLatch);
errno = save_errno;
}