mirror of
https://github.com/postgres/postgres.git
synced 2025-11-07 19:06:32 +03:00
process startup: Separate out BootstrapModeMain from AuxiliaryProcessMain.
There practically was no shared code between the two, once all the ifs are removed. And it was quite confusing that aux processes weren't actually started by the call to AuxiliaryProcessMain() in main(). There's more to do, AuxiliaryProcessMain() should move out of bootstrap.c, and BootstrapModeMain() shouldn't use/be part of AuxProcType. Author: Andres Freund <andres@anarazel.de> Reviewed-By: Kyotaro Horiguchi <horikyota.ntt@gmail.com> Reviewed-By: Robert Haas <robertmhaas@gmail.com> Discussion: https://postgr.es/m/20210802164124.ufo5buo4apl6yuvs@alap3.anarazel.de
This commit is contained in:
@@ -5026,6 +5026,10 @@ SubPostmasterMain(int argc, char *argv[])
|
||||
}
|
||||
if (strcmp(argv[1], "--forkaux") == 0)
|
||||
{
|
||||
AuxProcType auxtype;
|
||||
|
||||
Assert(argc == 4);
|
||||
|
||||
/* Restore basic shared memory pointers */
|
||||
InitShmemAccess(UsedShmemSegAddr);
|
||||
|
||||
@@ -5035,7 +5039,8 @@ SubPostmasterMain(int argc, char *argv[])
|
||||
/* Attach process to shared data structures */
|
||||
CreateSharedMemoryAndSemaphores();
|
||||
|
||||
AuxiliaryProcessMain(argc - 2, argv + 2); /* does not return */
|
||||
auxtype = atoi(argv[3]);
|
||||
AuxiliaryProcessMain(auxtype); /* does not return */
|
||||
}
|
||||
if (strcmp(argv[1], "--forkavlauncher") == 0)
|
||||
{
|
||||
@@ -5414,28 +5419,28 @@ static pid_t
|
||||
StartChildProcess(AuxProcType type)
|
||||
{
|
||||
pid_t pid;
|
||||
char *av[10];
|
||||
int ac = 0;
|
||||
char typebuf[32];
|
||||
|
||||
/*
|
||||
* Set up command-line arguments for subprocess
|
||||
*/
|
||||
av[ac++] = "postgres";
|
||||
|
||||
#ifdef EXEC_BACKEND
|
||||
av[ac++] = "--forkaux";
|
||||
av[ac++] = NULL; /* filled in by postmaster_forkexec */
|
||||
#endif
|
||||
{
|
||||
char *av[10];
|
||||
int ac = 0;
|
||||
char typebuf[32];
|
||||
|
||||
snprintf(typebuf, sizeof(typebuf), "-x%d", type);
|
||||
av[ac++] = typebuf;
|
||||
/*
|
||||
* Set up command-line arguments for subprocess
|
||||
*/
|
||||
av[ac++] = "postgres";
|
||||
av[ac++] = "--forkaux";
|
||||
av[ac++] = NULL; /* filled in by postmaster_forkexec */
|
||||
|
||||
av[ac] = NULL;
|
||||
Assert(ac < lengthof(av));
|
||||
snprintf(typebuf, sizeof(typebuf), "%d", type);
|
||||
av[ac++] = typebuf;
|
||||
|
||||
#ifdef EXEC_BACKEND
|
||||
pid = postmaster_forkexec(ac, av);
|
||||
av[ac] = NULL;
|
||||
Assert(ac < lengthof(av));
|
||||
|
||||
pid = postmaster_forkexec(ac, av);
|
||||
}
|
||||
#else /* !EXEC_BACKEND */
|
||||
pid = fork_process();
|
||||
|
||||
@@ -5451,7 +5456,7 @@ StartChildProcess(AuxProcType type)
|
||||
MemoryContextDelete(PostmasterContext);
|
||||
PostmasterContext = NULL;
|
||||
|
||||
AuxiliaryProcessMain(ac, av); /* does not return */
|
||||
AuxiliaryProcessMain(type); /* does not return */
|
||||
}
|
||||
#endif /* EXEC_BACKEND */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user