From ca7578d45477ee0cb33bdb62c863acfe098347b3 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 6 Nov 2001 00:38:26 +0000 Subject: [PATCH] The extra semaphore that proc.c now allocates for checkpoint processes should be accounted for in the PROC_SEM_MAP_ENTRIES() macro. Otherwise the ports that rely on this macro to size data structures are broken. Mea culpa. --- src/backend/storage/lmgr/proc.c | 9 ++++++--- src/include/storage/proc.h | 8 +++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 1b0058eaef..84118c78d3 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.114 2001/10/28 06:25:50 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.115 2001/11/06 00:38:26 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -124,10 +124,13 @@ InitProcGlobal(int maxBackends) /* * Compute size for ProcGlobal structure. Note we need one more sema - * besides those used for regular backends. + * besides those used for regular backends; this is accounted for in + * the PROC_SEM_MAP_ENTRIES macro. (We do it that way so that other + * modules that use PROC_SEM_MAP_ENTRIES(maxBackends) to size data + * structures don't have to know about this explicitly.) */ Assert(maxBackends > 0); - semMapEntries = PROC_SEM_MAP_ENTRIES(maxBackends + 1); + semMapEntries = PROC_SEM_MAP_ENTRIES(maxBackends); procGlobalSize = sizeof(PROC_HDR) + (semMapEntries - 1) *sizeof(SEM_MAP_ENTRY); /* Create or attach to the ProcGlobal shared structure */ diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index cba32ecec2..e1700b2372 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: proc.h,v 1.53 2001/11/05 17:46:35 momjian Exp $ + * $Id: proc.h,v 1.54 2001/11/06 00:38:26 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -93,10 +93,12 @@ extern PROC *MyProc; * in each set for identification purposes.) * * PROC_SEM_MAP_ENTRIES is the number of semaphore sets we need to allocate - * to keep track of up to maxBackends backends. + * to keep track of up to maxBackends backends. Note that we need one extra + * semaphore (see storage/lmgr/proc.c), so the computation may look wrong, + * but it's right. */ #define PROC_NSEMS_PER_SET 16 -#define PROC_SEM_MAP_ENTRIES(maxBackends) (((maxBackends)-1)/PROC_NSEMS_PER_SET+1) +#define PROC_SEM_MAP_ENTRIES(maxBackends) ((maxBackends)/PROC_NSEMS_PER_SET+1) typedef struct { -- 2.40.0