Re: Advice needed concerning Win32 signals

Поиск
Список
Период
Сортировка
От Magnus Hagander
Тема Re: Advice needed concerning Win32 signals
Дата
Msg-id 6BCB9D8A16AC4241919521715F4D8BCE92E747@algol.sollentuna.se
обсуждение исходный текст
Ответ на Advice needed concerning Win32 signals  (Thomas Hallgren <thomas.hallgren@home.se>)
Ответы Re: Advice needed concerning Win32 signals  (Thomas Hallgren <thomas.hallgren@home.se>)
Re: Advice needed concerning Win32 signals  (Thomas Hallgren <thomas.hallgren@home.se>)
Список pgsql-hackers
> Hi,
> I'm in the process of securing the PL/Java signal handling routines.
> Since a multi-threaded JVM is running and a signal can occur
> at any time in any thread, I need to trap some of them and
> make sure that they are executed in the main thread. Using
> Posix signals, this is easy. Here's a sample handler:
>
> static void pljavaStatementCancelHandler(int signum) {
>     if(pthread_self() == mainThread)
>        /*
>         * Call original handler
>         */
>         StatementCancelHandler(signum);
>     else
>        /*
>         * Dispatch to main thread.
>         */
>         pthread_kill(mainThread, signum); /* Send it to main
> thread */ }
>
> The mainThread was initialized when the handler was first registered.
>
>  From looking at the PostgreSQL signal handling routines for
> Win32, I realize that several threads are involved already.
> Perhaps all signals are indeed dispatched to the main thread
> already? I couldn't really figure it out. I need help from
> someone who knows more about this.

The win32 system itself doesn't have the concept of signals. Therefor,
the only signals being delivered are those delivered internally between
the postgresql processes (including those sent manually through pg_ctl).

These "fake signals" are dispatched on the main thread. They are
received by a worker thread, which will queue them up and set a flag,
and the main thread then polls this queue and delivers the actual
signal.

I have *no idea* how pthreads does this. pthread_kill() probably does
not know about *our* signal emulation layer, but somehow has it's own.
(as pthreads definitly aren't used in the backend, but I assume you're
somehow using them for pl/java anyway). Or perhaps that's just not
necessary and the example was for unix only?


//Magnus


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Greg Stark
Дата:
Сообщение: Re: slow IN() clause for many cases
Следующее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: slow IN() clause for many cases