Re: pgsql: Do all accesses to shared buffer headers

From: Neil Conway <neilc(at)samurai(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: Do all accesses to shared buffer headers
Date: 2005-10-12 23:36:30
Message-ID: 1129160190.8718.32.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On Wed, 2005-12-10 at 18:54 -0400, Tom Lane wrote:
> How would a typedef make it safer? I see no particular difference
> between omitting the "volatile" and choosing the wrong typedef.

IMHO it is notationally clearer to define a "BufferDescPtr" that
contains the "volatile" qualifier than to make sure that "volatile" is
used everywhere that it is needed -- obviously, neither approach is
fool-proof. But perhaps that's just me...

> We do however have here a New Coding Rule that's good for all parts
> of the backend: if you are accessing a spinlock-protected data structure
> then you should be using a volatile-qualified pointer for it.

I think this is worth documenting more clearly (I realize you added a
note in buf_internals.h, but perhaps a note in the spinlock headers
would be appropriate as well? The comment circa line 49 of s_lock.h
seems to need updating, for example.)

-Neil

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2005-10-13 00:06:47 pgsql: Don't try to remove duplicate OR-subclauses in
Previous Message Tom Lane 2005-10-12 23:19:23 pgsql: Fix spelling error, per Michael Fuhr.

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-10-13 00:27:32 Re: pgsql: Do all accesses to shared buffer headers through
Previous Message Kevin Grittner 2005-10-12 23:28:47 A costing analysis tool