Retire PG_SETMASK() macro.
In the 90s we needed to deal with computers that still had the
pre-standard signal masking APIs. That hasn't been relevant for a very
long time on Unix systems, and c94ae9d8
got rid of a remaining
dependency in our Windows porting code. PG_SETMASK didn't expose
save/restore functionality, so we'd already started using sigprocmask()
directly in places, creating the visual distraction of having two ways
to spell it. It's not part of the API that extensions are expected to
be using (but if they are, the change will be trivial). It seems like a
good time to drop the old macro and just call the standard POSIX
function.
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Discussion: https://postgr.es/m/CA%2BhUKG%2BKfQgrhHP2DLTohX1WwubaCBHmTzGnAEDPZ-Gug-Xskg%40mail.gmail.com
This commit is contained in:
parent
e0d70a91a0
commit
cdf6518ef0
|
@ -2755,7 +2755,7 @@ AbortTransaction(void)
|
|||
* handler. We do this fairly early in the sequence so that the timeout
|
||||
* infrastructure will be functional if needed while aborting.
|
||||
*/
|
||||
PG_SETMASK(&UnBlockSig);
|
||||
sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
|
||||
|
||||
/*
|
||||
* check the current transaction state
|
||||
|
@ -5115,7 +5115,7 @@ AbortSubTransaction(void)
|
|||
* handler. We do this fairly early in the sequence so that the timeout
|
||||
* infrastructure will be functional if needed while aborting.
|
||||
*/
|
||||
PG_SETMASK(&UnBlockSig);
|
||||
sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
|
||||
|
||||
/*
|
||||
* check the current transaction state
|
||||
|
|
|
@ -568,7 +568,7 @@ AutoVacLauncherMain(int argc, char *argv[])
|
|||
PG_exception_stack = &local_sigjmp_buf;
|
||||
|
||||
/* must unblock signals before calling rebuild_database_list */
|
||||
PG_SETMASK(&UnBlockSig);
|
||||
sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
|
||||
|
||||
/*
|
||||
* Set always-secure search path. Launcher doesn't connect to a database,
|
||||
|
@ -1589,7 +1589,7 @@ AutoVacWorkerMain(int argc, char *argv[])
|
|||
/* We can now handle ereport(ERROR) */
|
||||
PG_exception_stack = &local_sigjmp_buf;
|
||||
|
||||
PG_SETMASK(&UnBlockSig);
|
||||
sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
|
||||
|
||||
/*
|
||||
* Set always-secure search path, so malicious users can't redirect user
|
||||
|
|
|
@ -726,7 +726,7 @@ SanityCheckBackgroundWorker(BackgroundWorker *worker, int elevel)
|
|||
static void
|
||||
bgworker_die(SIGNAL_ARGS)
|
||||
{
|
||||
PG_SETMASK(&BlockSig);
|
||||
sigprocmask(SIG_SETMASK, &BlockSig, NULL);
|
||||
|
||||
ereport(FATAL,
|
||||
(errcode(ERRCODE_ADMIN_SHUTDOWN),
|
||||
|
|
|
@ -215,7 +215,7 @@ BackgroundWriterMain(void)
|
|||
/*
|
||||
* Unblock signals (they were blocked when the postmaster forked us)
|
||||
*/
|
||||
PG_SETMASK(&UnBlockSig);
|
||||
sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
|
||||
|
||||
/*
|
||||
* Reset hibernation state after any error.
|
||||
|
|
|
@ -326,7 +326,7 @@ CheckpointerMain(void)
|
|||
/*
|
||||
* Unblock signals (they were blocked when the postmaster forked us)
|
||||
*/
|
||||
PG_SETMASK(&UnBlockSig);
|
||||
sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
|
||||
|
||||
/*
|
||||
* Ensure all shared memory values are set correctly for the config. Doing
|
||||
|
|
|
@ -227,7 +227,7 @@ PgArchiverMain(void)
|
|||
pqsignal(SIGCHLD, SIG_DFL);
|
||||
|
||||
/* Unblock signals (they were blocked when the postmaster forked us) */
|
||||
PG_SETMASK(&UnBlockSig);
|
||||
sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
|
||||
|
||||
/* We shouldn't be launched unnecessarily. */
|
||||
Assert(XLogArchivingActive());
|
||||
|
|
|
@ -639,7 +639,7 @@ PostmasterMain(int argc, char *argv[])
|
|||
* postmaster/bgworker.c and postmaster/checkpointer.c.
|
||||
*/
|
||||
pqinitmask();
|
||||
PG_SETMASK(&BlockSig);
|
||||
sigprocmask(SIG_SETMASK, &BlockSig, NULL);
|
||||
|
||||
pqsignal(SIGHUP, handle_pm_reload_request_signal);
|
||||
pqsignal(SIGINT, handle_pm_shutdown_request_signal);
|
||||
|
@ -675,7 +675,7 @@ PostmasterMain(int argc, char *argv[])
|
|||
#endif
|
||||
|
||||
/* Begin accepting signals. */
|
||||
PG_SETMASK(&UnBlockSig);
|
||||
sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
|
||||
|
||||
/*
|
||||
* Options setup
|
||||
|
@ -4321,7 +4321,7 @@ BackendInitialize(Port *port)
|
|||
pqsignal(SIGTERM, process_startup_packet_die);
|
||||
/* SIGQUIT handler was already set up by InitPostmasterChild */
|
||||
InitializeTimeouts(); /* establishes SIGALRM handler */
|
||||
PG_SETMASK(&StartupBlockSig);
|
||||
sigprocmask(SIG_SETMASK, &StartupBlockSig, NULL);
|
||||
|
||||
/*
|
||||
* Get the remote host name and port for logging and status display.
|
||||
|
@ -4402,7 +4402,7 @@ BackendInitialize(Port *port)
|
|||
* Disable the timeout, and prevent SIGTERM again.
|
||||
*/
|
||||
disable_timeout(STARTUP_PACKET_TIMEOUT, false);
|
||||
PG_SETMASK(&BlockSig);
|
||||
sigprocmask(SIG_SETMASK, &BlockSig, NULL);
|
||||
|
||||
/*
|
||||
* As a safety check that nothing in startup has yet performed
|
||||
|
@ -5661,13 +5661,13 @@ BackgroundWorkerInitializeConnectionByOid(Oid dboid, Oid useroid, uint32 flags)
|
|||
void
|
||||
BackgroundWorkerBlockSignals(void)
|
||||
{
|
||||
PG_SETMASK(&BlockSig);
|
||||
sigprocmask(SIG_SETMASK, &BlockSig, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
BackgroundWorkerUnblockSignals(void)
|
||||
{
|
||||
PG_SETMASK(&UnBlockSig);
|
||||
sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
|
||||
}
|
||||
|
||||
#ifdef EXEC_BACKEND
|
||||
|
|
|
@ -259,7 +259,7 @@ StartupProcessMain(void)
|
|||
/*
|
||||
* Unblock signals (they were blocked when the postmaster forked us)
|
||||
*/
|
||||
PG_SETMASK(&UnBlockSig);
|
||||
sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
|
||||
|
||||
/*
|
||||
* Do what we came for.
|
||||
|
|
|
@ -263,7 +263,7 @@ SysLoggerMain(int argc, char *argv[])
|
|||
*/
|
||||
pqsignal(SIGCHLD, SIG_DFL);
|
||||
|
||||
PG_SETMASK(&UnBlockSig);
|
||||
sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
|
||||
|
||||
#ifdef WIN32
|
||||
/* Fire up separate data transfer thread */
|
||||
|
|
|
@ -205,7 +205,7 @@ WalWriterMain(void)
|
|||
/*
|
||||
* Unblock signals (they were blocked when the postmaster forked us)
|
||||
*/
|
||||
PG_SETMASK(&UnBlockSig);
|
||||
sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
|
||||
|
||||
/*
|
||||
* Reset hibernation state after any error.
|
||||
|
|
|
@ -293,7 +293,7 @@ WalReceiverMain(void)
|
|||
elog(ERROR, "libpqwalreceiver didn't initialize correctly");
|
||||
|
||||
/* Unblock signals (they were blocked when the postmaster forked us) */
|
||||
PG_SETMASK(&UnBlockSig);
|
||||
sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
|
||||
|
||||
/* Establish the connection to the primary for XLOG streaming */
|
||||
wrconn = walrcv_connect(conninfo, false,
|
||||
|
|
|
@ -2831,7 +2831,7 @@ void
|
|||
quickdie(SIGNAL_ARGS)
|
||||
{
|
||||
sigaddset(&BlockSig, SIGQUIT); /* prevent nested calls */
|
||||
PG_SETMASK(&BlockSig);
|
||||
sigprocmask(SIG_SETMASK, &BlockSig, NULL);
|
||||
|
||||
/*
|
||||
* Prevent interrupts while exiting; though we just blocked signals that
|
||||
|
@ -4129,7 +4129,7 @@ PostgresMain(const char *dbname, const char *username)
|
|||
BaseInit();
|
||||
|
||||
/* We need to allow SIGINT, etc during the initial transaction */
|
||||
PG_SETMASK(&UnBlockSig);
|
||||
sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
|
||||
|
||||
/*
|
||||
* General initialization.
|
||||
|
|
|
@ -159,7 +159,7 @@ InitPostmasterChild(void)
|
|||
pqsignal(SIGQUIT, SignalHandlerForCrashExit);
|
||||
|
||||
sigdelset(&BlockSig, SIGQUIT);
|
||||
PG_SETMASK(&BlockSig);
|
||||
sigprocmask(SIG_SETMASK, &BlockSig, NULL);
|
||||
|
||||
/* Request a signal if the postmaster dies, if possible. */
|
||||
PostmasterDeathSignalInit();
|
||||
|
@ -196,7 +196,7 @@ InitStandaloneProcess(const char *argv0)
|
|||
* But we don't unblock SIGQUIT or provide a default handler for it.
|
||||
*/
|
||||
pqinitmask();
|
||||
PG_SETMASK(&BlockSig);
|
||||
sigprocmask(SIG_SETMASK, &BlockSig, NULL);
|
||||
|
||||
/* Compute paths, no postmaster to inherit from */
|
||||
if (my_exec_path[0] == '\0')
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
|
||||
#include <signal.h>
|
||||
|
||||
#define PG_SETMASK(mask) sigprocmask(SIG_SETMASK, mask, NULL)
|
||||
|
||||
#ifdef WIN32
|
||||
/* Emulate POSIX sigset_t APIs on Windows */
|
||||
typedef int sigset_t;
|
||||
|
|
Loading…
Reference in New Issue