summaryrefslogtreecommitdiff
path: root/src/backend/storage
diff options
context:
space:
mode:
authorNathan Bossart <nathan@postgresql.org>2025-12-15 14:27:16 -0600
committerNathan Bossart <nathan@postgresql.org>2025-12-15 14:27:16 -0600
commit48d4a1423d2e92d10077365532d92e059ba2eb2e (patch)
treedeb5eb18eaef14743bff7889a3f3112cda58d5c6 /src/backend/storage
parent64bf53dd61ea3224020bb340725a4df6a27bc974 (diff)
Allow passing a pointer to GetNamedDSMSegment()'s init callback.
This commit adds a new "void *arg" parameter to GetNamedDSMSegment() that is passed to the initialization callback function. This is useful for reusing an initialization callback function for multiple DSM segments. Author: Zsolt Parragi <zsolt.parragi@percona.com> Reviewed-by: Sami Imseih <samimseih@gmail.com> Discussion: https://postgr.es/m/CAN4CZFMjh8TrT9ZhWgjVTzBDkYZi2a84BnZ8bM%2BfLPuq7Cirzg%40mail.gmail.com
Diffstat (limited to 'src/backend/storage')
-rw-r--r--src/backend/storage/ipc/dsm_registry.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/backend/storage/ipc/dsm_registry.c b/src/backend/storage/ipc/dsm_registry.c
index 66240318e83..072f9399969 100644
--- a/src/backend/storage/ipc/dsm_registry.c
+++ b/src/backend/storage/ipc/dsm_registry.c
@@ -180,11 +180,13 @@ init_dsm_registry(void)
* Initialize or attach a named DSM segment.
*
* This routine returns the address of the segment. init_callback is called to
- * initialize the segment when it is first created.
+ * initialize the segment when it is first created. 'arg' is passed through to
+ * the initialization callback function.
*/
void *
GetNamedDSMSegment(const char *name, size_t size,
- void (*init_callback) (void *ptr), bool *found)
+ void (*init_callback) (void *ptr, void *arg),
+ bool *found, void *arg)
{
DSMRegistryEntry *entry;
MemoryContext oldcontext;
@@ -235,7 +237,7 @@ GetNamedDSMSegment(const char *name, size_t size,
seg = dsm_create(size, 0);
if (init_callback)
- (*init_callback) (dsm_segment_address(seg));
+ (*init_callback) (dsm_segment_address(seg), arg);
dsm_pin_segment(seg);
dsm_pin_mapping(seg);