Re: Adding volatile qualifer

From: Tatsuo Ishii <ishii(at)postgresql(dot)org>
To: pgpool-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Adding volatile qualifer
Date: 2026-07-21 12:02:26
Message-ID: 20260721.210226.2051335232699705753.ishii@postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgpool-hackers

>> While looking into the Pgpool-II main source code, I noticed that
>> local pointer array "my_backend_status" is not volatile qualified,
>> while it should have been.
>>
>> BACKEND_STATUS *my_backend_status[MAX_NUM_BACKENDS]; /* Backend status buffer */
>>
>> This array members are initialized:
>>
>> for (i = 0; i < MAX_NUM_BACKENDS; i++)
>> {
>> my_backend_status[i] = &(BACKEND_INFO(i).backend_status);
>> }
>>
>> Without volatile, *(my_backend_status[i]) could read state value
>> because of compiler optimization. Since my_backend_status[i] is
>> referred to in popular VALID_BACKEND macro, we should fix it in all
>> supported branches.
>
> volatile qualifier should have been attached to the right hand side
> too. Attached v2 patch does it.

v2 patch pushed to all supported branches.
https://git.postgresql.org/gitweb/?p=pgpool2.git;a=commit;h=c2d464521ef017fd7aa76fc56c412c5af06fdb07

Regards,
--
Tatsuo Ishii
SRA OSS K.K.
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp

In response to

Browse pgpool-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2026-08-17 06:13:53 Re: Delimit query-cache key to prevent collisions
Previous Message Koshino Taiki 2026-07-21 06:01:46 Convert close_idle_connection (SIGUSR1) to flag-only handler with main-loop processing.