Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit ca7578d

Browse files
committed
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.
1 parent 0053ceb commit ca7578d

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/backend/storage/lmgr/proc.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.114 2001/10/28 06:25:50 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.115 2001/11/06 00:38:26 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -124,10 +124,13 @@ InitProcGlobal(int maxBackends)
124124

125125
/*
126126
* Compute size for ProcGlobal structure. Note we need one more sema
127-
* besides those used for regular backends.
127+
* besides those used for regular backends; this is accounted for in
128+
* the PROC_SEM_MAP_ENTRIES macro. (We do it that way so that other
129+
* modules that use PROC_SEM_MAP_ENTRIES(maxBackends) to size data
130+
* structures don't have to know about this explicitly.)
128131
*/
129132
Assert(maxBackends > 0);
130-
semMapEntries = PROC_SEM_MAP_ENTRIES(maxBackends + 1);
133+
semMapEntries = PROC_SEM_MAP_ENTRIES(maxBackends);
131134
procGlobalSize = sizeof(PROC_HDR) + (semMapEntries - 1) *sizeof(SEM_MAP_ENTRY);
132135

133136
/* Create or attach to the ProcGlobal shared structure */

src/include/storage/proc.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: proc.h,v 1.53 2001/11/05 17:46:35 momjian Exp $
10+
* $Id: proc.h,v 1.54 2001/11/06 00:38:26 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -93,10 +93,12 @@ extern PROC *MyProc;
9393
* in each set for identification purposes.)
9494
*
9595
* PROC_SEM_MAP_ENTRIES is the number of semaphore sets we need to allocate
96-
* to keep track of up to maxBackends backends.
96+
* to keep track of up to maxBackends backends. Note that we need one extra
97+
* semaphore (see storage/lmgr/proc.c), so the computation may look wrong,
98+
* but it's right.
9799
*/
98100
#define PROC_NSEMS_PER_SET 16
99-
#define PROC_SEM_MAP_ENTRIES(maxBackends) (((maxBackends)-1)/PROC_NSEMS_PER_SET+1)
101+
#define PROC_SEM_MAP_ENTRIES(maxBackends) ((maxBackends)/PROC_NSEMS_PER_SET+1)
100102

101103
typedef struct
102104
{

0 commit comments

Comments
 (0)