aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/access/transam/xlog.c2
-rw-r--r--src/backend/bootstrap/bootstrap.c20
-rw-r--r--src/backend/postmaster/bgwriter.c11
-rw-r--r--src/backend/postmaster/checkpointer.c13
-rw-r--r--src/backend/postmaster/walwriter.c4
-rw-r--r--src/backend/replication/walreceiver.c6
-rw-r--r--src/backend/storage/ipc/procsignal.c1
-rw-r--r--src/backend/storage/smgr/md.c7
8 files changed, 26 insertions, 38 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 3f3f9a3727b..a73cd6b9dec 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -8946,7 +8946,7 @@ get_sync_bit(int method)
* after its written. Also, walreceiver performs unaligned writes, which
* don't work with O_DIRECT, so it is required for correctness too.
*/
- if (!XLogIsNeeded() && !am_walreceiver)
+ if (!XLogIsNeeded() && !AmWalReceiverProcess())
o_direct_flag = PG_O_DIRECT;
switch (method)
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index e3ae92d540d..b7428829f37 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -63,6 +63,8 @@ static void cleanup(void);
* ----------------
*/
+AuxProcType MyAuxProcType = NotAnAuxProcess; /* declared in miscadmin.h */
+
Relation boot_reldesc; /* current relation descriptor */
Form_pg_attribute attrtypes[MAXATTR]; /* points to attribute info */
@@ -187,7 +189,6 @@ AuxiliaryProcessMain(int argc, char *argv[])
{
char *progname = argv[0];
int flag;
- AuxProcType auxType = CheckerProcess;
char *userDoption = NULL;
/*
@@ -228,6 +229,9 @@ AuxiliaryProcessMain(int argc, char *argv[])
argc--;
}
+ /* If no -x argument, we are a CheckerProcess */
+ MyAuxProcType = CheckerProcess;
+
while ((flag = getopt(argc, argv, "B:c:d:D:Fr:x:-:")) != -1)
{
switch (flag)
@@ -258,7 +262,7 @@ AuxiliaryProcessMain(int argc, char *argv[])
strlcpy(OutputFileName, optarg, MAXPGPATH);
break;
case 'x':
- auxType = atoi(optarg);
+ MyAuxProcType = atoi(optarg);
break;
case 'c':
case '-':
@@ -308,7 +312,7 @@ AuxiliaryProcessMain(int argc, char *argv[])
{
const char *statmsg;
- switch (auxType)
+ switch (MyAuxProcType)
{
case StartupProcess:
statmsg = "startup process";
@@ -374,15 +378,15 @@ AuxiliaryProcessMain(int argc, char *argv[])
/*
* Assign the ProcSignalSlot for an auxiliary process. Since it
* doesn't have a BackendId, the slot is statically allocated based on
- * the auxiliary process type (auxType). Backends use slots indexed
- * in the range from 1 to MaxBackends (inclusive), so we use
+ * the auxiliary process type (MyAuxProcType). Backends use slots
+ * indexed in the range from 1 to MaxBackends (inclusive), so we use
* MaxBackends + AuxProcType + 1 as the index of the slot for an
* auxiliary process.
*
* This will need rethinking if we ever want more than one of a
* particular auxiliary process type.
*/
- ProcSignalInit(MaxBackends + auxType + 1);
+ ProcSignalInit(MaxBackends + MyAuxProcType + 1);
/* finish setting up bufmgr.c */
InitBufferPoolBackend();
@@ -396,7 +400,7 @@ AuxiliaryProcessMain(int argc, char *argv[])
*/
SetProcessingMode(NormalProcessing);
- switch (auxType)
+ switch (MyAuxProcType)
{
case CheckerProcess:
/* don't set signals, they're useless here */
@@ -436,7 +440,7 @@ AuxiliaryProcessMain(int argc, char *argv[])
proc_exit(1); /* should never return */
default:
- elog(PANIC, "unrecognized process type: %d", auxType);
+ elog(PANIC, "unrecognized process type: %d", (int) MyAuxProcType);
proc_exit(1);
}
}
diff --git a/src/backend/postmaster/bgwriter.c b/src/backend/postmaster/bgwriter.c
index 5f93fccbfab..f98f138e9a6 100644
--- a/src/backend/postmaster/bgwriter.c
+++ b/src/backend/postmaster/bgwriter.c
@@ -74,11 +74,6 @@ int BgWriterDelay = 200;
static volatile sig_atomic_t got_SIGHUP = false;
static volatile sig_atomic_t shutdown_requested = false;
-/*
- * Private state
- */
-static bool am_bg_writer = false;
-
/* Signal handlers */
static void bg_quickdie(SIGNAL_ARGS);
@@ -90,8 +85,8 @@ static void bgwriter_sigusr1_handler(SIGNAL_ARGS);
/*
* Main entry point for bgwriter process
*
- * This is invoked from BootstrapMain, which has already created the basic
- * execution environment, but not enabled signals yet.
+ * This is invoked from AuxiliaryProcessMain, which has already created the
+ * basic execution environment, but not enabled signals yet.
*/
void
BackgroundWriterMain(void)
@@ -100,8 +95,6 @@ BackgroundWriterMain(void)
MemoryContext bgwriter_context;
bool prev_hibernate;
- am_bg_writer = true;
-
/*
* If possible, make this process a group leader, so that the postmaster
* can signal any child processes too. (bgwriter probably never has any
diff --git a/src/backend/postmaster/checkpointer.c b/src/backend/postmaster/checkpointer.c
index 92fd4276cd1..b8715ea6762 100644
--- a/src/backend/postmaster/checkpointer.c
+++ b/src/backend/postmaster/checkpointer.c
@@ -153,8 +153,6 @@ static volatile sig_atomic_t shutdown_requested = false;
/*
* Private state
*/
-static bool am_checkpointer = false;
-
static bool ckpt_active = false;
/* these values are valid when ckpt_active is true: */
@@ -185,8 +183,8 @@ static void ReqShutdownHandler(SIGNAL_ARGS);
/*
* Main entry point for checkpointer process
*
- * This is invoked from BootstrapMain, which has already created the basic
- * execution environment, but not enabled signals yet.
+ * This is invoked from AuxiliaryProcessMain, which has already created the
+ * basic execution environment, but not enabled signals yet.
*/
void
CheckpointerMain(void)
@@ -195,7 +193,6 @@ CheckpointerMain(void)
MemoryContext checkpointer_context;
CheckpointerShmem->checkpointer_pid = MyProcPid;
- am_checkpointer = true;
/*
* If possible, make this process a group leader, so that the postmaster
@@ -685,7 +682,7 @@ CheckpointWriteDelay(int flags, double progress)
static int absorb_counter = WRITES_PER_ABSORB;
/* Do nothing if checkpoint is being executed by non-checkpointer process */
- if (!am_checkpointer)
+ if (!AmCheckpointerProcess())
return;
/*
@@ -1129,7 +1126,7 @@ ForwardFsyncRequest(RelFileNode rnode, ForkNumber forknum, BlockNumber segno)
if (!IsUnderPostmaster)
return false; /* probably shouldn't even get here */
- if (am_checkpointer)
+ if (AmCheckpointerProcess())
elog(ERROR, "ForwardFsyncRequest must not be called in checkpointer");
LWLockAcquire(CheckpointerCommLock, LW_EXCLUSIVE);
@@ -1306,7 +1303,7 @@ AbsorbFsyncRequests(void)
CheckpointerRequest *request;
int n;
- if (!am_checkpointer)
+ if (!AmCheckpointerProcess())
return;
/*
diff --git a/src/backend/postmaster/walwriter.c b/src/backend/postmaster/walwriter.c
index b7b85125553..8a794955810 100644
--- a/src/backend/postmaster/walwriter.c
+++ b/src/backend/postmaster/walwriter.c
@@ -89,8 +89,8 @@ static void walwriter_sigusr1_handler(SIGNAL_ARGS);
/*
* Main entry point for walwriter process
*
- * This is invoked from BootstrapMain, which has already created the basic
- * execution environment, but not enabled signals yet.
+ * This is invoked from AuxiliaryProcessMain, which has already created the
+ * basic execution environment, but not enabled signals yet.
*/
void
WalWriterMain(void)
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index fd119d38cbb..b0a8b197603 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -52,10 +52,8 @@
#include "utils/resowner.h"
#include "utils/timestamp.h"
-/* Global variable to indicate if this process is a walreceiver process */
-bool am_walreceiver;
-/* GUC variable */
+/* GUC variables */
int wal_receiver_status_interval;
bool hot_standby_feedback;
@@ -176,8 +174,6 @@ WalReceiverMain(void)
/* use volatile pointer to prevent code rearrangement */
volatile WalRcvData *walrcv = WalRcv;
- am_walreceiver = true;
-
/*
* WalRcv should be set up already (if we are a backend, we inherit this
* by fork() or EXEC_BACKEND mechanism from the postmaster).
diff --git a/src/backend/storage/ipc/procsignal.c b/src/backend/storage/ipc/procsignal.c
index 3d7e85fba47..0f0d4dd48df 100644
--- a/src/backend/storage/ipc/procsignal.c
+++ b/src/backend/storage/ipc/procsignal.c
@@ -17,7 +17,6 @@
#include <signal.h>
#include <unistd.h>
-#include "bootstrap/bootstrap.h"
#include "commands/async.h"
#include "miscadmin.h"
#include "storage/latch.h"
diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c
index c05315d8849..f074cedca59 100644
--- a/src/backend/storage/smgr/md.c
+++ b/src/backend/storage/smgr/md.c
@@ -196,11 +196,10 @@ mdinit(void)
/*
* Create pending-operations hashtable if we need it. Currently, we need
- * it if we are standalone (not under a postmaster) OR if we are a
- * bootstrap-mode subprocess of a postmaster (that is, a startup or
- * checkpointer process).
+ * it if we are standalone (not under a postmaster) or if we are a startup
+ * or checkpointer auxiliary process.
*/
- if (!IsUnderPostmaster || IsBootstrapProcessingMode())
+ if (!IsUnderPostmaster || AmStartupProcess() || AmCheckpointerProcess())
{
HASHCTL hash_ctl;