help in allocating shared module within a module

From: Luca Ferrari <fluca1978(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: help in allocating shared module within a module
Date: 2024-12-23 17:31:33
Message-ID: CAKoxK+7f2m1ruBMoY8C=sucR2W2t8jDg-BXHzhfcc6EcO6BtWg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,
hope this is the right place to ask for, otherwise please point me in
the right resource.
I'm trying to develop a module that needs shared memory between
background workers.

The _PG_init calls a function to reserve the shared memory, which in
turn calls RequestAddinShmemSpace, which seems to fail. In fact, I
never got the debug line after the call to RequestAddinShmemSpaec and
_PG_init does not conitnue.

Here is my code skeleton:

void
_PG_init(void)
{

if ( ! process_shared_preload_libraries_in_progress )
return;

// set up the GUCs
_define_gucs();

// set up the shared memory
_create_shared_memory();

...
}

void
_create_shared_memory()
{
Size estimated_size = 10136:

elog( DEBUG2, "shared allocation %lu", estimated_size );

RequestAddinShmemSpace( estimated_size );

elog(DEBUG2, "never reached!" );
...
}

What am I missing here?

Thanks,
Luca

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jelte Fennema-Nio 2024-12-23 17:46:16 Re: Add new protocol message to change GUCs for usage with future protocol-only GUCs
Previous Message Tom Lane 2024-12-23 16:26:41 Re: Using Expanded Objects other than Arrays from plpgsql