Here is a first sketch at Win32 signal handling. First a couple of
* This is just two files. It is not integrated with postgresql yet.
* Uses named pipes. Shared mem was slightly faster, named pipes a lot
cleaner. And the signal handlers themselves should not be performance
* Does *not* use user APCs. Why? Well, we had to use polling. And with
user APCs we'd have to go into kernel mode (however briefly) on every
poll. I replaced that with a simple counter that is checked. Thast way
we don't slow down the main path of the program much.
* It is then checked again while protected with a critical section, to
make sure we don't setp on our own toes from two threads.
* A user APC is queued on every signal anyway. This is only to break out
of SleepEx/WaitForMultipleObjectsEx etc functions. Normally, we pick the
signals up with polling.
A couple of questions that need answering:
* Where to put the polling. We need to find a reasonable limited number
of places. They just need PG_POLL_SIGNALS() there to go. Also, do we
want this one #ifdef:ed in every place, or just #define it to nothing at
all on non-windows platforms?
* Where to put the functions. Right now, it's just a separate file. Do
we want to keep it in separate files, or put it in existing files with
#ifdef:s? Or combination?
* Function names - I haven't looked at naming conventions at all :-)
* We need to replace any blocking waits (such as select() and sleep())
with "Ex functions" if we want signals to fire while waiting.
Probably a bunch more things I forgot to write right now.
Oh, and I've included two very small testfiles - "pgsignal_srvtest.c"
which is a sample server and "pgkill.c" which is a sample client. Very
ugly code, but it should show how it's intended to be used :-)
Anyway. Comments on these points in particular, and in the whole thing
in general? Workable path?
Description: application/octet-stream (469 bytes)
Description: application/octet-stream (5.8 KB)
Description: application/octet-stream (2.6 KB)
pgsql-patches by date
|Next:||From: Bruce Momjian||Date: 2004-01-08 20:44:24|
|Subject: Re: psql \i handling ~ in specified file name|
|Previous:||From: Jan Wieck||Date: 2004-01-08 19:26:09|
|Subject: Re: fork/exec patch: pre-CreateProcess finalization|
pgsql-hackers-win32 by date
|Next:||From: Merlin Moncure||Date: 2004-01-08 21:08:19|
|Subject: Re: Win32 signal code - first try|
|Previous:||From: Andrew Dunstan||Date: 2004-01-08 19:50:46|
|Subject: Re: Signals on Win32 (yet again)|