Accessing shared memory in a proc_exit callback

Lists: pgsql-hackers
From: "Claudio Rossi" <wind(dot)claudio(at)inwind(dot)it>
To: "pgsql-hackers" <pgsql-hackers(at)postgresql(dot)org>
Cc: "wind\(dot)claudio" <wind(dot)claudio(at)inwind(dot)it>
Subject: Accessing shared memory in a proc_exit callback
Date: 2006-11-20 15:18:48
Message-ID: J91BVC$A604AE391ECC076021F002B50B669E78@libero.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello, I'm hacking postgresql code to add some custom features but I met the following problem:

I need to call a function right before frontend disconnects, so I looked for the section where frontend closes down the socket in PostgresMain (postgres.c)and I read the comment under "case 'X'" which states not to add code there but to set up a proc_exit callback. Then I looked at proc_exit code and here comes my problem: proc_exit calls shmem_exit BEFORE executing callbacks, but my function needs to access shared memory. My temporarily solution was to modify proc_exit, scanning callbacks to find my function and executing it before shmem_exit (I get a signal 11 otherwise): is it a good solution? Is there a more appropriate section to add a function call right before frontend disconnects than a proc_exit callback? Thank you.

Regards,
Claudio Rossi

------------------------------------------------------
Consolidamento.Una sola rata più bassa per i tuoi finanziamenti e, in più, liquidità! www.mutuionline.it
http://click.libero.it/mutuionline20nov


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Claudio Rossi" <wind(dot)claudio(at)inwind(dot)it>
Cc: "pgsql-hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Accessing shared memory in a proc_exit callback
Date: 2006-11-20 16:08:03
Message-ID: 7066.1164038883@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

"Claudio Rossi" <wind(dot)claudio(at)inwind(dot)it> writes:
> Is there a more appropriate section to add a function call right before frontend disconnects than a proc_exit callback? Thank you.

on_shmem_exit

regards, tom lane