aboutsummaryrefslogtreecommitdiff
path: root/src/backend/storage/lmgr/proc.c
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2023-12-03 16:39:18 +0200
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2023-12-03 16:39:18 +0200
commitfd5e8b440dfd633be74e3dd3382d4a9038dba24f (patch)
tree18777d875424975c85d7e0e416f527e220a1d127 /src/backend/storage/lmgr/proc.c
parent388491f1e5e63fe97c7cca26d18b64321973d423 (diff)
downloadpostgresql-fd5e8b440dfd633be74e3dd3382d4a9038dba24f.tar.gz
postgresql-fd5e8b440dfd633be74e3dd3382d4a9038dba24f.zip
Refactor how InitProcess is called
The order of process initialization steps is now more consistent between !EXEC_BACKEND and EXEC_BACKEND modes. InitProcess() is called at the same place in either mode. We can now also move the AttachSharedMemoryStructs() call into InitProcess() itself. This reduces the number of "#ifdef EXEC_BACKEND" blocks. Reviewed-by: Tristan Partin, Andres Freund, Alexander Lakhin Discussion: https://www.postgresql.org/message-id/7a59b073-5b5b-151e-7ed3-8b01ff7ce9ef@iki.fi
Diffstat (limited to 'src/backend/storage/lmgr/proc.c')
-rw-r--r--src/backend/storage/lmgr/proc.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c
index 6648c6e5e7e..b6451d9d083 100644
--- a/src/backend/storage/lmgr/proc.c
+++ b/src/backend/storage/lmgr/proc.c
@@ -291,7 +291,7 @@ InitProcGlobal(void)
}
/*
- * InitProcess -- initialize a per-process data structure for this backend
+ * InitProcess -- initialize a per-process PGPROC entry for this backend
*/
void
InitProcess(void)
@@ -461,6 +461,16 @@ InitProcess(void)
*/
InitLWLockAccess();
InitDeadLockChecking();
+
+#ifdef EXEC_BACKEND
+
+ /*
+ * Initialize backend-local pointers to all the shared data structures.
+ * (We couldn't do this until now because it needs LWLocks.)
+ */
+ if (IsUnderPostmaster)
+ AttachSharedMemoryStructs();
+#endif
}
/*
@@ -487,7 +497,7 @@ InitProcessPhase2(void)
}
/*
- * InitAuxiliaryProcess -- create a per-auxiliary-process data structure
+ * InitAuxiliaryProcess -- create a PGPROC entry for an auxiliary process
*
* This is called by bgwriter and similar processes so that they will have a
* MyProc value that's real enough to let them wait for LWLocks. The PGPROC
@@ -621,6 +631,16 @@ InitAuxiliaryProcess(void)
* acquired in aux processes.)
*/
InitLWLockAccess();
+
+#ifdef EXEC_BACKEND
+
+ /*
+ * Initialize backend-local pointers to all the shared data structures.
+ * (We couldn't do this until now because it needs LWLocks.)
+ */
+ if (IsUnderPostmaster)
+ AttachSharedMemoryStructs();
+#endif
}
/*