From 8e8a0becb335529c66a9f82f88e1419e49b458ae Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Wed, 11 Mar 2020 16:36:40 +0100 Subject: Unify several ways to tracking backend type Add a new global variable MyBackendType that uses the same BackendType enum that was previously only used by the stats collector. That way several duplicate ways of checking what type a particular process is can be simplified. Since it's no longer just for stats, move to miscinit.c and rename existing functions to match the expanded purpose. Reviewed-by: Julien Rouhaud Reviewed-by: Kuntal Ghosh Reviewed-by: Alvaro Herrera Discussion: https://www.postgresql.org/message-id/flat/c65e5196-4f04-4ead-9353-6088c19615a3@2ndquadrant.com --- src/backend/bootstrap/bootstrap.c | 48 ++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 28 deletions(-) (limited to 'src/backend/bootstrap/bootstrap.c') diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c index 7923d1ec9b2..5480a024e05 100644 --- a/src/backend/bootstrap/bootstrap.c +++ b/src/backend/bootstrap/bootstrap.c @@ -314,36 +314,28 @@ AuxiliaryProcessMain(int argc, char *argv[]) proc_exit(1); } - /* - * Identify myself via ps - */ - if (IsUnderPostmaster) + switch (MyAuxProcType) { - const char *statmsg; - - switch (MyAuxProcType) - { - case StartupProcess: - statmsg = pgstat_get_backend_desc(B_STARTUP); - break; - case BgWriterProcess: - statmsg = pgstat_get_backend_desc(B_BG_WRITER); - break; - case CheckpointerProcess: - statmsg = pgstat_get_backend_desc(B_CHECKPOINTER); - break; - case WalWriterProcess: - statmsg = pgstat_get_backend_desc(B_WAL_WRITER); - break; - case WalReceiverProcess: - statmsg = pgstat_get_backend_desc(B_WAL_RECEIVER); - break; - default: - statmsg = "??? process"; - break; - } - init_ps_display(statmsg); + case StartupProcess: + MyBackendType = B_STARTUP; + break; + case BgWriterProcess: + MyBackendType = B_BG_WRITER; + break; + case CheckpointerProcess: + MyBackendType = B_CHECKPOINTER; + break; + case WalWriterProcess: + MyBackendType = B_WAL_WRITER; + break; + case WalReceiverProcess: + MyBackendType = B_WAL_RECEIVER; + break; + default: + MyBackendType = B_INVALID; } + if (IsUnderPostmaster) + init_ps_display(NULL); /* Acquire configuration parameters, unless inherited from postmaster */ if (!IsUnderPostmaster) -- cgit v1.2.3