Thread

  1. Re: Proposal: Add a callback data parameter to GetNamedDSMSegment

    Sami Imseih <samimseih@gmail.com> — 2025-12-12T20:56:39Z

    > 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)