Re: convert various variables to atomics - Mailing list pgsql-hackers

From Nathan Bossart
Subject Re: convert various variables to atomics
Date
Msg-id amDGRZxnlmTVjkCe@nathan
Whole thread
In response to Re: convert various variables to atomics  (Andres Freund <andres@anarazel.de>)
Responses Re: Restore vacuum_delay_point() in GIN posting-tree leaf vacuum
List pgsql-hackers
On Wed, Jul 22, 2026 at 09:19:39AM -0400, Andres Freund wrote:
> On 2026-07-22 09:06:44 -0400, Nathan Bossart wrote:
>> >      /* Buffer id of the buffer that Startup process waits for pin on, or -1 */
>> > -    int            startupBufferPinWaitBufId;
>> > +    pg_atomic_uint32 startupBufferPinWaitBufId;
>> 
>> I may just be undercaffeinated, but what is wrong with this case?  AFAICT
>> the casting should work as expected, and I see other examples that do
>> something similar, like avLauncherProc.
> 
> The comment says -1, which doesn't really make sense for an unsigned variable.

Ah.  It looks like we could use 0 as the sentinel and simplify the call
sites.  They subtract one before calling SetStartupBufferPinWaitBufId() and
add one after calling GetStartupBufferPinWaitBufId().

-- 
nathan



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: convert various variables to atomics
Next
From: Ayush Tiwari
Date:
Subject: Re: Incorrect check in 037_except.pl?