mirror of
https://github.com/postgres/postgres.git
synced 2025-08-12 15:23:02 +03:00
This patch reserves the last superuser_reserved_connections slots for
connections by the superuser only. This patch replaces the last patch I sent a couple of days ago. It closes a connection that has not been authorised by a superuser if it would leave less than the GUC variable ReservedBackends (superuser_reserved_connections in postgres.conf) backend process slots free in the SISeg. This differs to the first patch which only reserved the last ReservedBackends slots in the procState array. This has made the free slot test more expensive due to the use of a lock. After thinking about a comment on the first patch I've also made it a fatal error if the number of reserved slots is not less than the maximum number of connections. Nigel J. Andrews
This commit is contained in:
@@ -37,7 +37,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.285 2002/08/18 03:03:25 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.286 2002/08/29 21:02:12 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
*
|
||||
@@ -151,6 +151,18 @@ char *VirtualHost;
|
||||
*/
|
||||
int MaxBackends = DEF_MAXBACKENDS;
|
||||
|
||||
/*
|
||||
* ReservedBackends is the number of backends reserved for superuser use.
|
||||
* This number is taken out of the pool size given by MaxBackends so
|
||||
* number of backend slots available to none super users is
|
||||
* (MaxBackends - ReservedBackends). Note, existing super user
|
||||
* connections are not taken into account once this lower limit has
|
||||
* been reached, i.e. superuser connections made before the lower limit
|
||||
* is reached always count towards that limit and are not taken from
|
||||
* ReservedBackends.
|
||||
*/
|
||||
int ReservedBackends = 2;
|
||||
|
||||
|
||||
static char *progname = (char *) NULL;
|
||||
|
||||
@@ -567,6 +579,12 @@ PostmasterMain(int argc, char *argv[])
|
||||
|
||||
ProcessConfigFile(PGC_POSTMASTER);
|
||||
|
||||
/*
|
||||
* Force an exit if ReservedBackends is not less than MaxBackends.
|
||||
*/
|
||||
if (ReservedBackends >= MaxBackends)
|
||||
elog(FATAL,"superuser_reserved_connections must be less than max_connections.");
|
||||
|
||||
/*
|
||||
* Now that we are done processing the postmaster arguments, reset
|
||||
* getopt(3) library so that it will work correctly in subprocesses.
|
||||
|
Reference in New Issue
Block a user