diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 22cb0b8..d1cceba 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -157,7 +157,8 @@ void InitProcGlobal(void) { PGPROC *procs; - int i; + int i, + j; bool found; uint32 TotalProcs = MaxBackends + NUM_AUXILIARY_PROCS; @@ -222,6 +223,10 @@ InitProcGlobal(void) 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])); } /* @@ -243,7 +248,6 @@ InitProcess(void) { /* 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 @@ -303,8 +307,8 @@ InitProcess(void) 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; @@ -326,8 +330,6 @@ InitProcess(void) MyProc->lwWaitLink = NULL; MyProc->waitLock = NULL; MyProc->waitProcLock = NULL; - for (i = 0; i < NUM_LOCK_PARTITIONS; i++) - SHMQueueInit(&(MyProc->myProcLocks[i])); MyProc->recoveryConflictPending = false; /* Initialize fields for sync rep */ @@ -408,7 +410,6 @@ InitAuxiliaryProcess(void) { PGPROC *auxproc; int proctype; - int i; /* * ProcGlobal should be set up already (if we are a backend, we inherit @@ -455,8 +456,8 @@ InitAuxiliaryProcess(void) 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; @@ -473,8 +474,6 @@ InitAuxiliaryProcess(void) MyProc->lwWaitLink = NULL; MyProc->waitLock = NULL; MyProc->waitProcLock = NULL; - for (i = 0; i < NUM_LOCK_PARTITIONS; i++) - SHMQueueInit(&(MyProc->myProcLocks[i])); /* * Acquire ownership of the PGPROC's latch, so that we can use WaitLatch.