Re: Confusing variable naming in LWLockRelease

2025-02-09 Thread Jacob Brazeal
> I believe it refers to the state of the lock prior to lock acquisition; not prior to subtraction. That definitely makes sense as a way to read this variable in context, but after reviewing other usages of old_state in lwlock.c, I tend to think that this is an outlier usage and maybe the naming w

Re: Confusing variable naming in LWLockRelease

2025-02-05 Thread Jeff Davis
On Wed, 2025-01-29 at 23:16 -0800, Jacob Brazeal wrote: > Here the variable name "oldstate" leads one to believe that the value > is fetched before the sub operation, similar to some other usages in > lwlock.c. I believe it refers to the state of the lock prior to lock acquisition; not prior to su

Confusing variable naming in LWLockRelease

2025-01-29 Thread Jacob Brazeal
Hello all, In the LWLockRelease function, we have the following snippet: */** * * Release my hold on lock, after that it can immediately be acquired by * others, even if we still have to wakeup other waiters. */ if (mode == LW_EXCLUSIVE) oldstate = pg_atomic_sub_fetch_u32(&lock->state, LW_V