Re: Proposal: Add a callback data parameter to GetNamedDSMSegment

From: Sami Imseih <samimseih(at)gmail(dot)com>
To: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Cc: Nathan Bossart <nathandbossart(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Proposal: Add a callback data parameter to GetNamedDSMSegment
Date: 2025-12-12 00:28:20
Message-ID: CAA5RZ0ssnuQx3L54Aea+00wSxXHZtu=diCAK-8E54h3GbxDn+Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> +const char* forwardedData = "ForwardedData";
> +
> static void
> -init_tranche(void *ptr)
> +init_tranche(void *ptr, const char *name, void *arg)
> {
> int *tranche_id = (int *) ptr;
>
> - *tranche_id = LWLockNewTrancheId("test_dsa");
> + if (arg != forwardedData) {
> + elog(ERROR, "Didn't receive expected arg pointer");
> + }
> +
> + *tranche_id = LWLockNewTrancheId(name);
> }
>
> As otherwise we no longer test the value of the pointer in any of the
> tests with the additional name parameter.

Good call adding the tests. I do get compilation errors though with
v3, due to passing a const to a void pointer. I think this test could be
made better by checking that the arg data matches some data that
we expect.

```
-init_tranche(void *ptr)
+init_tranche(void *ptr, const char *name, void *arg)
{
int *tranche_id = (int *) ptr;
- *tranche_id = LWLockNewTrancheId("test_dsa");
+ /* Verify arg if given */
+ if (arg && strcmp(name, (char *) arg) != 0)
+ elog(ERROR, "didn't receive expected arg data");
+
+ *tranche_id = LWLockNewTrancheId(name);
}
```

--
Sami Imseih
Amazon Web Services (AWS)

Attachment Content-Type Size
v4-0001-Pass-name-and-callback-data-to-GetNamedDSMSegment.patch application/octet-stream 8.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jelte Fennema-Nio 2025-12-12 00:36:08 Re: Periodic authorization expiration checks using GoAway message
Previous Message Noah Misch 2025-12-12 00:24:37 Re: Inval reliability, especially for inplace updates