Re: Fix condition in shm_toc and remove unused function shm_toc_freespace.

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: Zhang Mingli <zmlpostgres(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Fix condition in shm_toc and remove unused function shm_toc_freespace.
Date: 2023-01-12 08:54:40
Message-ID: CAMbWs49f3M1ZrFuiQE5AoWqTERUUXdoeKFg6Di6BuYWFSZ24pA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jan 12, 2023 at 2:50 PM Zhang Mingli <zmlpostgres(at)gmail(dot)com> wrote:

> On Jan 12, 2023, 14:34 +0800, Zhang Mingli <zmlpostgres(at)gmail(dot)com>, wrote:
>
> Some conditions in shm_toc_insert and shm_toc_allocate are bogus, like:
> if (toc_bytes + nbytes > total_bytes || toc_bytes + nbytes < toc_bytes)
> Remove the condition `toc_bytes + nbytes < toc_bytes` and take a
> sizeof(shm_entry) into account in shm_toc_allocate though
> shm_toc_allocate does that too.
>
> shm_toc_insert does that too, and we can report error earlier.
>

I don't think we should consider sizeof(shm_toc_entry) in the 'if'
condition in shm_toc_allocate, as this function is not in charge of
allocating a new TOC entry. That's what shm_toc_insert does.

Other parts of this patch look good to me.

Thanks
Richard

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jelte Fennema 2023-01-12 09:10:02 Re: [EXTERNAL] Re: [PATCH] Support using "all" for the db user in pg_ident.conf
Previous Message Anthonin Bonnefoy 2023-01-12 08:45:31 Re: Flush SLRU counters in checkpointer process