InitProcGlobal(void)
{
PGPROC *procs;
- int i;
+ int i,
+ j;
bool found;
uint32 TotalProcs = MaxBackends + NUM_AUXILIARY_PROCS;
procs[i].links.next = (SHM_QUEUE *) ProcGlobal->autovacFreeProcs;
ProcGlobal->autovacFreeProcs = &procs[i];
}
+
+ /* Initialize myProcLocks[] shared memory queues. */
+ for (j = 0; j < NUM_LOCK_PARTITIONS; j++)
+ SHMQueueInit(&(procs[i].myProcLocks[j]));
}
/*
{
/* use volatile pointer to prevent code rearrangement */
volatile PROC_HDR *procglobal = ProcGlobal;
- int i;
/*
* ProcGlobal should be set up already (if we are a backend, we inherit
MarkPostmasterChildActive();
/*
- * Initialize all fields of MyProc, except for the semaphore and latch,
- * which were prepared for us by InitProcGlobal.
+ * Initialize all fields of MyProc, except for those previously initialized
+ * by InitProcGlobal.
*/
SHMQueueElemInit(&(MyProc->links));
MyProc->waitStatus = STATUS_OK;
MyProc->lwWaitLink = NULL;
MyProc->waitLock = NULL;
MyProc->waitProcLock = NULL;
- for (i = 0; i < NUM_LOCK_PARTITIONS; i++)
- SHMQueueInit(&(MyProc->myProcLocks[i]));
+#ifdef USE_ASSERT_CHECKING
+ if (assert_enabled)
+ {
+ int i;
+
+ /* Last process should have released all locks. */
+ for (i = 0; i < NUM_LOCK_PARTITIONS; i++)
+ Assert(SHMQueueEmpty(&(MyProc->myProcLocks[i])));
+ }
+#endif
MyProc->recoveryConflictPending = false;
/* Initialize fields for sync rep */
{
PGPROC *auxproc;
int proctype;
- int i;
/*
* ProcGlobal should be set up already (if we are a backend, we inherit
SpinLockRelease(ProcStructLock);
/*
- * Initialize all fields of MyProc, except for the semaphore and latch,
- * which were prepared for us by InitProcGlobal.
+ * Initialize all fields of MyProc, except for those previously initialized
+ * by InitProcGlobal.
*/
SHMQueueElemInit(&(MyProc->links));
MyProc->waitStatus = STATUS_OK;
MyProc->lwWaitLink = NULL;
MyProc->waitLock = NULL;
MyProc->waitProcLock = NULL;
- for (i = 0; i < NUM_LOCK_PARTITIONS; i++)
- SHMQueueInit(&(MyProc->myProcLocks[i]));
+#ifdef USE_ASSERT_CHECKING
+ if (assert_enabled)
+ {
+ int i;
+
+ /* Last process should have released all locks. */
+ for (i = 0; i < NUM_LOCK_PARTITIONS; i++)
+ Assert(SHMQueueEmpty(&(MyProc->myProcLocks[i])));
+ }
+#endif
/*
* Acquire ownership of the PGPROC's latch, so that we can use WaitLatch.
/* Make sure we're out of the sync rep lists */
SyncRepCleanupAtProcExit();
+#ifdef USE_ASSERT_CHECKING
+ if (assert_enabled)
+ {
+ int i;
+
+ /* Last process should have released all locks. */
+ for (i = 0; i < NUM_LOCK_PARTITIONS; i++)
+ Assert(SHMQueueEmpty(&(MyProc->myProcLocks[i])));
+ }
+#endif
+
/*
* Release any LW locks I am holding. There really shouldn't be any, but
* it's cheap to check again before we cut the knees off the LWLock