Move shmem allocator's fields from PGShmemHeader to its own struct

For readability. It was a slight modularity violation to have fields
in PGShmemHeader that were only used by the allocator code in
shmem.c. And it was inconsistent that ShmemLock was nevertheless not
stored there. Moving all the allocator-related fields to a separate
struct makes it more consistent and modular, and removes the need to
allocate and pass ShmemLock separately via BackendParameters.

Merge InitShmemAccess() and InitShmemAllocation() into a single
function that initializes the struct when called from postmaster, and
when called from backends in EXEC_BACKEND mode, re-establishes the
global variables. That's similar to all the *ShmemInit() functions
that we have.

Co-authored-by: Ashutosh Bapat <[email protected]>
Discussion: 
https://www.postgresql.org/message-id/caexhw5unrb9ot4pdo54qao025mxfx4mfyrd9k15ocqe-exn...@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/e2362eb2bd1459319dacaeaa5dc886dbca546b96

Modified Files
--------------
src/backend/port/sysv_shmem.c           |   2 +-
src/backend/port/win32_shmem.c          |   2 +-
src/backend/postmaster/launch_backend.c |   7 +-
src/backend/storage/ipc/ipci.c          |   4 +-
src/backend/storage/ipc/shmem.c         | 163 +++++++++++++++-----------------
src/include/storage/pg_shmem.h          |   4 +-
src/include/storage/shmem.h             |   3 +-
src/tools/pgindent/typedefs.list        |   1 +
8 files changed, 83 insertions(+), 103 deletions(-)

Reply via email to