Hello,
On Fri, Dec 22, 2017 at 03:05:25PM +0300, Maksim Milyutin wrote:
> Hi, hackers!
>
>
> I want to propose the patch that allows to define custom signals and their
> handlers on extension side.
>
I've looked a little bit on the patch. The patch applyes and regression tests pass.
I have a couple comments.
> The relationship between custom signals and
> assigned handlers (function addresses) is replicated from postmaster to
> child processes including working backends.
I think this happens only if a custom signal registered during initializing shared_preload_libraries.
But from RegisterCustomProcSignalHandler()'s implementation I see that you can register the signal anytime. Am I
wrong?
If so then custom signal handlers may not work as expected.
What is purpose of AssignCustomProcSignalHandler() function? This function can erase a handler set by another
extension.
For example, extension 1 set handler passing reason PROCSIG_CUSTOM_1, and extension 2 set another handler passing
reasonPROCSIG_CUSTOM_1 too. Here the handler of the extension 2 will be purged.
> +
> + Assert(reason >= PROCSIG_CUSTOM_1 && reason <= PROCSIG_CUSTOM_N);
> +
I think it is not good to use asserts within AssignCustomProcSignalHandler() and GetCustomProcSignalHandler(). Because
thisfunctions can be executed by an external extension, and it may pass a reason outside this boundary. It will be
betterif the reason will be checked in runtime.
But it is fine for this assert within CustomSignalInterrupt().
--
Arthur Zakirov
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company