Simplify Win32 Signaling code
This patch simplified Win32 signaling code per discussion in hackers. In
this implementation, each process will have a named (by its pid) mutex,
named shared memory area and named event in global namespace. The process
is
sending/receiving signals as the following:
(*) the process who kill the signal:
- Grab the named mutex, set signal bit in target process's shared memory
area and SetEvent(), then it is done;
(*) the process who should receive the signal:
- the main thread of this process could be awakened by the event from
waiting status(like semop()) or CHECK_FOR_INTERRUPTS() actively; -- there
is
no other threads of the process;
Details could be found in this thread and follows:
http://archives.postgresql.org/pgsql-hackers/2005-05/msg01388.php
Regards,
Qingqing
Attachments:
signaling.patchtext/plain; charset=US-ASCII; name=signaling.patchDownload+422-428
This patch simplified Win32 signaling code per discussion in
hackers. In this implementation, each process will have a
named (by its pid) mutex, named shared memory area and named
event in global namespace. The process is sending/receiving
signals as the following:(*) the process who kill the signal:
- Grab the named mutex, set signal bit in target process's
shared memory area and SetEvent(), then it is done;(*) the process who should receive the signal:
- the main thread of this process could be awakened by the
event from waiting status(like semop()) or
CHECK_FOR_INTERRUPTS() actively; -- there is no other threads
of the process;Details could be found in this thread and follows:
http://archives.postgresql.org/pgsql-hackers/2005-05/msg01388.php
Looking at this patch reminds me of another discussion we had:
Signals sent by the postmaster *before the signaling code is running in
the child* has to be handled.
This is handled in the curernt code by creating the pipe in the
postmaster and then inheriting it. You'll need something similar in this
one - create the stuff in the postmaster and inherit it down. (this is
the initial_signal_pipe and pgwin32_create_signal_listener(), which you
removed)
Sorry, forgot to bring this up earlier because I had completely forgot
it. You'll find some details if you search the archives, I beleive.
//Magnus
Import Notes
Resolved by subject fallback
""Magnus Hagander"" <mha@sollentuna.net> writes
Looking at this patch reminds me of another discussion we had:
Signals sent by the postmaster *before the signaling code is running in
the child* has to be handled.This is handled in the curernt code by creating the pipe in the
postmaster and then inheriting it. You'll need something similar in this
one - create the stuff in the postmaster and inherit it down. (this is
the initial_signal_pipe and pgwin32_create_signal_listener(), which you
removed)Sorry, forgot to bring this up earlier because I had completely forgot
it. You'll find some details if you search the archives, I beleive.
Is this thread:
http://archives.postgresql.org/pgsql-hackers-win32/2004-11/msg00000.php
It is my fault to ignore this - I just *simply* removed those lines ... I
will look into the problem and come up with a patch.
Regards,
Qingqing
In thread:
http://archives.postgresql.org/pgsql-hackers-win32/2004-11/msg00010.php
---
Do we actually need to pass the handle, or could the subprocess reopen
the pipe for itself?
Nope, we need to pass the handle. Only one process can be the
server-side of the pipe, and once the postmaster has opened it, the
child process can't do it - the only way to get it is through
inheritance.
---
In current implementation, we can reopen it, but the problem is that when
postmaster should close those three (shmem, mutex, event) handles? So the
best way is still "Postmaster create them, duplicate these handles in
BackendParameters and the child inheritates them". Do I got your meaning?
Regards,
Qingqing