Re: Proposal: Add a callback data parameter to GetNamedDSMSegment - Mailing list pgsql-hackers

From Sami Imseih
Subject Re: Proposal: Add a callback data parameter to GetNamedDSMSegment
Date
Msg-id CAA5RZ0ssnuQx3L54Aea+00wSxXHZtu=diCAK-8E54h3GbxDn+Q@mail.gmail.com
Whole thread Raw
In response to Re: Proposal: Add a callback data parameter to GetNamedDSMSegment  (Zsolt Parragi <zsolt.parragi@percona.com>)
List 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

pgsql-hackers by date:

Previous
From: Noah Misch
Date:
Subject: Re: Inval reliability, especially for inplace updates
Next
From: Jelte Fennema-Nio
Date:
Subject: Re: Periodic authorization expiration checks using GoAway message