mirror of
https://github.com/postgres/postgres.git
synced 2025-11-07 19:06:32 +03:00
Refactor CreateSharedMemoryAndSemaphores
For clarity, have separate functions for *creating* the shared memory and semaphores at postmaster or single-user backend startup, and for *attaching* to existing shared memory structures in EXEC_BACKEND case. CreateSharedMemoryAndSemaphores() is now called only at postmaster startup, and a new AttachSharedMemoryStructs() function is called at backend startup in EXEC_BACKEND mode. Reviewed-by: Tristan Partin, Andres Freund Discussion: https://www.postgresql.org/message-id/7a59b073-5b5b-151e-7ed3-8b01ff7ce9ef@iki.fi
This commit is contained in:
@@ -4917,11 +4917,11 @@ SubPostmasterMain(int argc, char *argv[])
|
||||
/* Restore basic shared memory pointers */
|
||||
InitShmemAccess(UsedShmemSegAddr);
|
||||
|
||||
/* Need a PGPROC to run CreateSharedMemoryAndSemaphores */
|
||||
/* Need a PGPROC to run AttachSharedMemoryStructs */
|
||||
InitProcess();
|
||||
|
||||
/* Attach process to shared data structures */
|
||||
CreateSharedMemoryAndSemaphores();
|
||||
AttachSharedMemoryStructs();
|
||||
|
||||
/* And run the backend */
|
||||
BackendRun(&port); /* does not return */
|
||||
@@ -4935,11 +4935,11 @@ SubPostmasterMain(int argc, char *argv[])
|
||||
/* Restore basic shared memory pointers */
|
||||
InitShmemAccess(UsedShmemSegAddr);
|
||||
|
||||
/* Need a PGPROC to run CreateSharedMemoryAndSemaphores */
|
||||
/* Need a PGPROC to run AttachSharedMemoryStructs */
|
||||
InitAuxiliaryProcess();
|
||||
|
||||
/* Attach process to shared data structures */
|
||||
CreateSharedMemoryAndSemaphores();
|
||||
AttachSharedMemoryStructs();
|
||||
|
||||
auxtype = atoi(argv[3]);
|
||||
AuxiliaryProcessMain(auxtype); /* does not return */
|
||||
@@ -4949,11 +4949,11 @@ SubPostmasterMain(int argc, char *argv[])
|
||||
/* Restore basic shared memory pointers */
|
||||
InitShmemAccess(UsedShmemSegAddr);
|
||||
|
||||
/* Need a PGPROC to run CreateSharedMemoryAndSemaphores */
|
||||
/* Need a PGPROC to run AttachSharedMemoryStructs */
|
||||
InitProcess();
|
||||
|
||||
/* Attach process to shared data structures */
|
||||
CreateSharedMemoryAndSemaphores();
|
||||
AttachSharedMemoryStructs();
|
||||
|
||||
AutoVacLauncherMain(argc - 2, argv + 2); /* does not return */
|
||||
}
|
||||
@@ -4962,11 +4962,11 @@ SubPostmasterMain(int argc, char *argv[])
|
||||
/* Restore basic shared memory pointers */
|
||||
InitShmemAccess(UsedShmemSegAddr);
|
||||
|
||||
/* Need a PGPROC to run CreateSharedMemoryAndSemaphores */
|
||||
/* Need a PGPROC to run AttachSharedMemoryStructs */
|
||||
InitProcess();
|
||||
|
||||
/* Attach process to shared data structures */
|
||||
CreateSharedMemoryAndSemaphores();
|
||||
AttachSharedMemoryStructs();
|
||||
|
||||
AutoVacWorkerMain(argc - 2, argv + 2); /* does not return */
|
||||
}
|
||||
@@ -4980,11 +4980,11 @@ SubPostmasterMain(int argc, char *argv[])
|
||||
/* Restore basic shared memory pointers */
|
||||
InitShmemAccess(UsedShmemSegAddr);
|
||||
|
||||
/* Need a PGPROC to run CreateSharedMemoryAndSemaphores */
|
||||
/* Need a PGPROC to run AttachSharedMemoryStructs */
|
||||
InitProcess();
|
||||
|
||||
/* Attach process to shared data structures */
|
||||
CreateSharedMemoryAndSemaphores();
|
||||
AttachSharedMemoryStructs();
|
||||
|
||||
/* Fetch MyBgworkerEntry from shared memory */
|
||||
shmem_slot = atoi(argv[1] + 15);
|
||||
|
||||
Reference in New Issue
Block a user