aboutsummaryrefslogtreecommitdiff
path: root/src/backend/storage/lmgr/proc.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>1999-02-19 07:10:48 +0000
committerTom Lane <tgl@sss.pgh.pa.us>1999-02-19 07:10:48 +0000
commit4c313931353f33e75d3f3eec9b7806fb8f15ab33 (patch)
treea7a5dd935db377eabcea5c688562a746555f7766 /src/backend/storage/lmgr/proc.c
parente77b630cf0c1501008b3b72b5621f2951ef82b71 (diff)
downloadpostgresql-4c313931353f33e75d3f3eec9b7806fb8f15ab33.tar.gz
postgresql-4c313931353f33e75d3f3eec9b7806fb8f15ab33.zip
Reorder startup ops so that if preallocation of semas fails,
postmaster will release whatever it did get before dying.
Diffstat (limited to 'src/backend/storage/lmgr/proc.c')
-rw-r--r--src/backend/storage/lmgr/proc.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c
index ae8fb17fcab..7452270fdf4 100644
--- a/src/backend/storage/lmgr/proc.c
+++ b/src/backend/storage/lmgr/proc.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.49 1999/02/19 06:06:08 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.50 1999/02/19 07:10:48 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -46,7 +46,7 @@
* This is so that we can support more backends. (system-wide semaphore
* sets run out pretty fast.) -ay 4/95
*
- * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.49 1999/02/19 06:06:08 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.50 1999/02/19 07:10:48 tgl Exp $
*/
#include <sys/time.h>
#include <unistd.h>
@@ -79,6 +79,7 @@
static void HandleDeadLock(int sig);
static PROC *ProcWakeup(PROC *proc, int errType);
+static void ProcFreeAllSemaphores(void);
#define DeadlockCheckTimer pg_options[OPT_DEADLOCKTIMEOUT]
@@ -135,6 +136,8 @@ InitProcGlobal(IPCKey key, int maxBackends)
/* --------------------
* We're the first - initialize.
+ * XXX if found should ever be true, it is a sign of impending doom ...
+ * ought to complain if so?
* --------------------
*/
if (!found)
@@ -145,6 +148,12 @@ InitProcGlobal(IPCKey key, int maxBackends)
ProcGlobal->currKey = IPCGetProcessSemaphoreInitKey(key);
for (i = 0; i < MAX_PROC_SEMS / PROC_NSEMS_PER_SET; i++)
ProcGlobal->freeSemMap[i] = 0;
+
+ /* Arrange to delete semas on exit --- set this up now so that
+ * we will clean up if pre-allocation fails...
+ */
+ on_shmem_exit(ProcFreeAllSemaphores, NULL);
+
/* Pre-create the semaphores for the first maxBackends processes */
for (i = 0;
i < (maxBackends+PROC_NSEMS_PER_SET-1) / PROC_NSEMS_PER_SET;
@@ -924,7 +933,7 @@ ProcFreeSem(IpcSemaphoreKey semKey, int semNum)
* destroying shared state for a failed set of backends.
* Free up all the semaphores allocated to the lmgrs of the backends.
*/
-void
+static void
ProcFreeAllSemaphores()
{
int i;