{
ProcSignalSlot *slot;
uint64 barrier_generation;
+ uint32 old_pss_pid;
if (MyProcNumber < 0)
elog(ERROR, "MyProcNumber not set");
elog(ERROR, "unexpected MyProcNumber %d in ProcSignalInit (max %d)", MyProcNumber, NumProcSignalSlots);
slot = &ProcSignal->psh_slot[MyProcNumber];
- /* sanity check */
SpinLockAcquire(&slot->pss_mutex);
- if (pg_atomic_read_u32(&slot->pss_pid) != 0)
- {
- SpinLockRelease(&slot->pss_mutex);
- elog(LOG, "process %d taking over ProcSignal slot %d, but it's not empty",
- MyProcPid, MyProcNumber);
- }
+
+ /* Value used for sanity check below */
+ old_pss_pid = pg_atomic_read_u32(&slot->pss_pid);
/* Clear out any leftover signal reasons */
MemSet(slot->pss_signalFlags, 0, NUM_PROCSIGNALS * sizeof(sig_atomic_t));
SpinLockRelease(&slot->pss_mutex);
+ /* Spinlock is released, do the check */
+ if (old_pss_pid != 0)
+ elog(LOG, "process %d taking over ProcSignal slot %d, but it's not empty",
+ MyProcPid, MyProcNumber);
+
/* Remember slot location for CheckProcSignal */
MyProcSignalSlot = slot;