agora inbox for pgsql-hackers@postgresql.org  
help / color / mirror / Atom feed
From: Nathan Bossart <nathandbossart@gmail.com>
To: Andres Freund <andres@anarazel.de>
Cc: Peter Eisentraut <peter@eisentraut.org>
Cc: pgsql-hackers@postgresql.org
Subject: Re: convert various variables to atomics
Date: Wed, 22 Jul 2026 09:31:49 -0400
Message-ID: <amDGRZxnlmTVjkCe@nathan> (raw)
In-Reply-To: <ycvruij7554tlhw6w7bg4lqtibd52qguo52iojyou7ejdv5jrm@qyyr5f3hdsue>
References: <alAJeRRzehDjLaF1@nathan>
	<9d8c317d-d933-46c7-b675-4b9308eaca2b@eisentraut.org>
	<amDAZAVob4DJjUfW@nathan>
	<ycvruij7554tlhw6w7bg4lqtibd52qguo52iojyou7ejdv5jrm@qyyr5f3hdsue>

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






view thread (22+ messages)  latest in thread

Message-ID: <amDGRZxnlmTVjkCe@nathan>
Permalink:  ../amDGRZxnlmTVjkCe@nathan/
Also on:    postgresql.org/message-id/amDGRZxnlmTVjkCe@nathan

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: nathandbossart@gmail.com, andres@anarazel.de, peter@eisentraut.org
  Subject: Re: convert various variables to atomics
  In-Reply-To: <amDGRZxnlmTVjkCe@nathan>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox