Thread
-
Re: Proposal: Add a callback data parameter to GetNamedDSMSegment
Sami Imseih <samimseih@gmail.com> — 2025-12-12T00:28:20Z
> +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)