Skip site navigation (1) Skip section navigation (2)

Win32 signal code - first try

From: "Magnus Hagander" <mha(at)sollentuna(dot)net>
To: <pgsql-patches(at)postgresql(dot)org>
Cc: "pgsql-hackers-win32" <pgsql-hackers-win32(at)postgresql(dot)org>
Subject: Win32 signal code - first try
Date: 2004-01-08 20:27:24
Message-ID: 6BCB9D8A16AC4241919521715F4D8BCE2A6A5E@algol.sollentuna.se (view raw or flat)
Thread:
Lists: pgsql-hackers-win32pgsql-patches
Hi!

Here is a first sketch at Win32 signal handling. First a couple of
comments:

* 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
critical, AFAICS.

* 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?


//Magnus

Attachment: pgkill.c
Description: application/octet-stream (469 bytes)
Attachment: pgsignal_srvtest.c
Description: application/octet-stream (480 bytes)
Attachment: pgsignal_w32.c
Description: application/octet-stream (5.8 KB)
Attachment: pgsignal_w32.h
Description: application/octet-stream (2.6 KB)

pgsql-patches by date

Next:From: Bruce MomjianDate: 2004-01-08 20:44:24
Subject: Re: psql \i handling ~ in specified file name
Previous:From: Jan WieckDate: 2004-01-08 19:26:09
Subject: Re: fork/exec patch: pre-CreateProcess finalization

pgsql-hackers-win32 by date

Next:From: Merlin MoncureDate: 2004-01-08 21:08:19
Subject: Re: Win32 signal code - first try
Previous:From: Andrew DunstanDate: 2004-01-08 19:50:46
Subject: Re: Signals on Win32 (yet again)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group