Rename StartBackgroundWorker() to BackgroundWorkerMain().
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Mon, 9 Oct 2023 08:52:09 +0000 (11:52 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Mon, 9 Oct 2023 08:52:09 +0000 (11:52 +0300)
The comment claimed that it is "called from postmaster", but it is
actually called in the child process, pretty early in the process
initialization. I guess you could interpret "called from postmaster"
to mean that, but it seems wrong to me. Rename the function to be
consistent with other functions with similar role.

Reviewed-by: Thomas Munro
Discussion: https://www.postgresql.org/message-id/4f95c1fc-ad3c-7974-3a8c-6faa3931804c@iki.fi

src/backend/postmaster/bgworker.c
src/backend/postmaster/postmaster.c
src/include/postmaster/bgworker_internals.h

index cc66c61dee792c52d2482a927c1f52b2274670f8..48a9924527edce1258dcb1180f6c0b3ae2969762 100644 (file)
@@ -741,13 +741,10 @@ bgworker_die(SIGNAL_ARGS)
 }
 
 /*
- * Start a new background worker
- *
- * This is the main entry point for background worker, to be called from
- * postmaster.
+ * Main entry point for background worker processes.
  */
 void
-StartBackgroundWorker(void)
+BackgroundWorkerMain(void)
 {
        sigjmp_buf      local_sigjmp_buf;
        BackgroundWorker *worker = MyBgworkerEntry;
index 583c9b03246352dd5515848a865c28a70550088b..0761b38bf880d845bc1921e0b966eb5600735a60 100644 (file)
@@ -4982,7 +4982,7 @@ SubPostmasterMain(int argc, char *argv[])
                shmem_slot = atoi(argv[1] + 15);
                MyBgworkerEntry = BackgroundWorkerEntry(shmem_slot);
 
-               StartBackgroundWorker();
+               BackgroundWorkerMain();
        }
        if (strcmp(argv[1], "--forklog") == 0)
        {
@@ -5721,7 +5721,7 @@ do_start_bgworker(RegisteredBgWorker *rw)
                        MemoryContextDelete(PostmasterContext);
                        PostmasterContext = NULL;
 
-                       StartBackgroundWorker();
+                       BackgroundWorkerMain();
 
                        exit(1);                        /* should not get here */
                        break;
index 4ad63fd9bd7f918c3decc154557c7aaee9d117fe..09df054fcce4ba2040c1ba7d75e7b8fc8199202b 100644 (file)
@@ -54,8 +54,8 @@ extern void BackgroundWorkerStopNotifications(pid_t pid);
 extern void ForgetUnstartedBackgroundWorkers(void);
 extern void ResetBackgroundWorkerCrashTimes(void);
 
-/* Function to start a background worker, called from postmaster.c */
-extern void StartBackgroundWorker(void) pg_attribute_noreturn();
+/* Entry point for background worker processes */
+extern void BackgroundWorkerMain(void) pg_attribute_noreturn();
 
 #ifdef EXEC_BACKEND
 extern BackgroundWorker *BackgroundWorkerEntry(int slotno);