From 28f3915b73f75bd1b50ba070f56b34241fe53fd1 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Thu, 22 Feb 2024 01:21:34 +0200 Subject: Remove superfluous 'pgprocno' field from PGPROC It was always just the index of the PGPROC entry from the beginning of the proc array. Introduce a macro to compute it from the pointer instead. Reviewed-by: Andres Freund Discussion: https://www.postgresql.org/message-id/8171f1aa-496f-46a6-afc3-c46fe7a9b407@iki.fi --- src/backend/storage/lmgr/condition_variable.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/backend/storage/lmgr/condition_variable.c') diff --git a/src/backend/storage/lmgr/condition_variable.c b/src/backend/storage/lmgr/condition_variable.c index e2d6d685220..10fdae19dcc 100644 --- a/src/backend/storage/lmgr/condition_variable.c +++ b/src/backend/storage/lmgr/condition_variable.c @@ -57,7 +57,7 @@ ConditionVariableInit(ConditionVariable *cv) void ConditionVariablePrepareToSleep(ConditionVariable *cv) { - int pgprocno = MyProc->pgprocno; + int pgprocno = MyProcNumber; /* * If some other sleep is already prepared, cancel it; this is necessary @@ -181,10 +181,10 @@ ConditionVariableTimedSleep(ConditionVariable *cv, long timeout, * guarantee not to return spuriously, we'll avoid this obvious case. */ SpinLockAcquire(&cv->mutex); - if (!proclist_contains(&cv->wakeup, MyProc->pgprocno, cvWaitLink)) + if (!proclist_contains(&cv->wakeup, MyProcNumber, cvWaitLink)) { done = true; - proclist_push_tail(&cv->wakeup, MyProc->pgprocno, cvWaitLink); + proclist_push_tail(&cv->wakeup, MyProcNumber, cvWaitLink); } SpinLockRelease(&cv->mutex); @@ -236,8 +236,8 @@ ConditionVariableCancelSleep(void) return false; SpinLockAcquire(&cv->mutex); - if (proclist_contains(&cv->wakeup, MyProc->pgprocno, cvWaitLink)) - proclist_delete(&cv->wakeup, MyProc->pgprocno, cvWaitLink); + if (proclist_contains(&cv->wakeup, MyProcNumber, cvWaitLink)) + proclist_delete(&cv->wakeup, MyProcNumber, cvWaitLink); else signaled = true; SpinLockRelease(&cv->mutex); @@ -281,7 +281,7 @@ ConditionVariableSignal(ConditionVariable *cv) void ConditionVariableBroadcast(ConditionVariable *cv) { - int pgprocno = MyProc->pgprocno; + int pgprocno = MyProcNumber; PGPROC *proc = NULL; bool have_sentinel = false; -- cgit v1.2.3