Remove postmaster.c's reset_shared() wrapper function.
authorTom Lane <[email protected]>
Sat, 16 Jul 2022 16:26:19 +0000 (12:26 -0400)
committerTom Lane <[email protected]>
Sat, 16 Jul 2022 16:26:35 +0000 (12:26 -0400)
reset_shared just invokes CreateSharedMemoryAndSemaphores, so let's
get rid of it and invoke that directly.  This removes a confusing
seeming-inconsistency between the postmaster's startup sequence
and the startup sequence used in standalone mode.

Nathan Bossart, reviewed by Pavel Borisov

Discussion: https://postgr.es/m/20220329221702.GA559657@nathanxps13

src/backend/postmaster/postmaster.c

index d7257e4056b0f3ea6b5443164e07f9b14520db0a..1c2545752666c59a6cf7e21f3f1d66ff1893d02a 100644 (file)
@@ -391,7 +391,6 @@ static void getInstallationPaths(const char *argv0);
 static void checkControlFile(void);
 static Port *ConnCreate(int serverFd);
 static void ConnFree(Port *port);
-static void reset_shared(void);
 static void SIGHUP_handler(SIGNAL_ARGS);
 static void pmdie(SIGNAL_ARGS);
 static void reaper(SIGNAL_ARGS);
@@ -1081,8 +1080,12 @@ PostmasterMain(int argc, char *argv[])
 
    /*
     * Set up shared memory and semaphores.
+    *
+    * Note: if using SysV shmem and/or semas, each postmaster startup will
+    * normally choose the same IPC keys.  This helps ensure that we will
+    * clean up dead IPC objects if the postmaster crashes and is restarted.
     */
-   reset_shared();
+   CreateSharedMemoryAndSemaphores();
 
    /*
     * Estimate number of openable files.  This must happen after setting up
@@ -2723,23 +2726,6 @@ InitProcessGlobals(void)
 }
 
 
-/*
- * reset_shared -- reset shared memory and semaphores
- */
-static void
-reset_shared(void)
-{
-   /*
-    * Create or re-create shared memory and semaphores.
-    *
-    * Note: in each "cycle of life" we will normally assign the same IPC keys
-    * (if using SysV shmem and/or semas).  This helps ensure that we will
-    * clean up dead IPC objects if the postmaster crashes and is restarted.
-    */
-   CreateSharedMemoryAndSemaphores();
-}
-
-
 /*
  * SIGHUP -- reread config files, and tell children to do same
  */
@@ -4022,7 +4008,8 @@ PostmasterStateMachine(void)
        /* re-read control file into local memory */
        LocalProcessControlFile(true);
 
-       reset_shared();
+       /* re-create shared memory and semaphores */
+       CreateSharedMemoryAndSemaphores();
 
        StartupPID = StartupDataBase();
        Assert(StartupPID != 0);