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 CAA5RZ0uJiK8N+Oi0ci__QSHF_tV2sjzqPh5m=P91PqviOhT-Uw@mail.gmail.com
Whole thread Raw
In response to Re: Proposal: Add a callback data parameter to GetNamedDSMSegment  (Nathan Bossart <nathandbossart@gmail.com>)
Responses Re: Proposal: Add a callback data parameter to GetNamedDSMSegment
Re: Proposal: Add a callback data parameter to GetNamedDSMSegment
List pgsql-hackers
> On Fri, Dec 12, 2025 at 12:48:52PM -0600, Sami Imseih wrote:
> > As far as testing, I did not think it's worth it since in the cases out
> > there now a NULL void * will result in an error when calling
> > LWLockNewTrancheId.
>
> I think we should pass NULL to all the existing in-tree calls to
> GetNamedDSMSegment(), except for perhaps a new test in test_dsm_registry
> that verifies the pointer value in the initialization function.  In all the
> other cases, there's no issue with hard-coding the tranche names, so we can
> keep those simple.

fair point. In that case why don't we just keep:

```
 static void
-init_tdr_dsm(void *ptr)
+init_tdr_dsm(void *ptr, void *arg)
 {
        TestDSMRegistryStruct *dsm = (TestDSMRegistryStruct *) ptr;

-       LWLockInitialize(&dsm->lck, LWLockNewTrancheId("test_dsm_registry"));
+       LWLockInitialize(&dsm->lck, LWLockNewTrancheId((char *) arg));
        dsm->val = 0;
 }

@@ -60,6 +60,7 @@ tdr_attach_shmem(void)
        tdr_dsm = GetNamedDSMSegment("test_dsm_registry_dsm",

sizeof(TestDSMRegistryStruct),
                                                                 init_tdr_dsm,
+
"test_dsm_registry",
                                                                 &found);

        if (tdr_dsa == NULL)
```

instead of creating a new test? For the other GetNamedDSMSegment
calls, I'll pass
NULL to the void * and hard code the tranche name in the init callback.

--
Sami Imseih
Amazon Web Services (AWS)



pgsql-hackers by date:

Previous
From: Bryan Green
Date:
Subject: Re: [PATCH] Fix severe performance regression with gettext 0.20+ on Windows
Next
From: Zsolt Parragi
Date:
Subject: Re: Proposal: Add a callback data parameter to GetNamedDSMSegment