Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4c31393

Browse files
committed
Reorder startup ops so that if preallocation of semas fails,
postmaster will release whatever it did get before dying.
1 parente77b630 commit4c31393

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

‎src/backend/storage/ipc/ipci.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipci.c,v 1.19 1999/02/1906:06:04 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipci.c,v 1.20 1999/02/1907:10:47 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -101,7 +101,6 @@ CreateSharedMemoryAndSemaphores(IPCKey key, int maxBackends)
101101
* ----------------
102102
*/
103103
InitProcGlobal(key,maxBackends);
104-
on_shmem_exit(ProcFreeAllSemaphores,NULL);
105104

106105
CreateSharedInvalidationState(key);
107106
}

‎src/backend/storage/lmgr/proc.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.49 1999/02/1906:06:08 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.50 1999/02/1907:10:48 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -46,7 +46,7 @@
4646
*This is so that we can support more backends. (system-wide semaphore
4747
*sets run out pretty fast.) -ay 4/95
4848
*
49-
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.49 1999/02/1906:06:08 tgl Exp $
49+
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.50 1999/02/1907:10:48 tgl Exp $
5050
*/
5151
#include<sys/time.h>
5252
#include<unistd.h>
@@ -79,6 +79,7 @@
7979

8080
staticvoidHandleDeadLock(intsig);
8181
staticPROC*ProcWakeup(PROC*proc,interrType);
82+
staticvoidProcFreeAllSemaphores(void);
8283

8384
#defineDeadlockCheckTimer pg_options[OPT_DEADLOCKTIMEOUT]
8485

@@ -135,6 +136,8 @@ InitProcGlobal(IPCKey key, int maxBackends)
135136

136137
/* --------------------
137138
* We're the first - initialize.
139+
* XXX if found should ever be true, it is a sign of impending doom ...
140+
* ought to complain if so?
138141
* --------------------
139142
*/
140143
if (!found)
@@ -145,6 +148,12 @@ InitProcGlobal(IPCKey key, int maxBackends)
145148
ProcGlobal->currKey=IPCGetProcessSemaphoreInitKey(key);
146149
for (i=0;i<MAX_PROC_SEMS /PROC_NSEMS_PER_SET;i++)
147150
ProcGlobal->freeSemMap[i]=0;
151+
152+
/* Arrange to delete semas on exit --- set this up now so that
153+
* we will clean up if pre-allocation fails...
154+
*/
155+
on_shmem_exit(ProcFreeAllSemaphores,NULL);
156+
148157
/* Pre-create the semaphores for the first maxBackends processes */
149158
for (i=0;
150159
i< (maxBackends+PROC_NSEMS_PER_SET-1) /PROC_NSEMS_PER_SET;
@@ -924,7 +933,7 @@ ProcFreeSem(IpcSemaphoreKey semKey, int semNum)
924933
* destroying shared state for a failed set of backends.
925934
* Free up all the semaphores allocated to the lmgrs of the backends.
926935
*/
927-
void
936+
staticvoid
928937
ProcFreeAllSemaphores()
929938
{
930939
inti;

‎src/include/storage/proc.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: proc.h,v 1.19 1999/02/1906:06:37 tgl Exp $
9+
* $Id: proc.h,v 1.20 1999/02/1907:10:47 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -122,6 +122,5 @@ extern int ProcLockWakeup(PROC_QUEUE *queue, LOCKMETHOD lockmethod,
122122
LOCK*lock);
123123
externvoidProcAddLock(SHM_QUEUE*elem);
124124
externvoidProcReleaseSpins(PROC*proc);
125-
externvoidProcFreeAllSemaphores(void);
126125

127126
#endif/* PROC_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp