From aa64f23b02924724eafbd9eadbf26d85df30a12b Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Tue, 8 Feb 2022 15:52:40 -0500 Subject: Remove MaxBackends variable in favor of GetMaxBackends() function. Previously, it was really easy to write code that accessed MaxBackends before we'd actually initialized it, especially when coding up an extension. To make this less error-prune, introduce a new function GetMaxBackends() which should be used to obtain the correct value. This will ERROR if called too early. Demote the global variable to a file-level static, so that nobody can peak at it directly. Nathan Bossart. Idea by Andres Freund. Review by Greg Sabino Mullane, by Michael Paquier (who had doubts about the approach), and by me. Discussion: http://postgr.es/m/20210802224204.bckcikl45uezv5e4@alap3.anarazel.de --- src/backend/postmaster/auxprocess.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/backend/postmaster/auxprocess.c') diff --git a/src/backend/postmaster/auxprocess.c b/src/backend/postmaster/auxprocess.c index 39ac4490db1..0587e45920a 100644 --- a/src/backend/postmaster/auxprocess.c +++ b/src/backend/postmaster/auxprocess.c @@ -116,7 +116,7 @@ AuxiliaryProcessMain(AuxProcType auxtype) * This will need rethinking if we ever want more than one of a particular * auxiliary process type. */ - ProcSignalInit(MaxBackends + MyAuxProcType + 1); + ProcSignalInit(GetMaxBackends() + MyAuxProcType + 1); /* * Auxiliary processes don't run transactions, but they may need a -- cgit v1.2.3