Re: What (not) to do in signal handlers

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: What (not) to do in signal handlers
Дата
Msg-id 18682.992542720@sss.pgh.pa.us
обсуждение исходный текст
Ответ на What (not) to do in signal handlers  (Peter Eisentraut <peter_e@gmx.net>)
Ответы Re: What (not) to do in signal handlers  (ncm@zembu.com (Nathan Myers))
Список pgsql-hackers
Peter Eisentraut <peter_e@gmx.net> writes:
> I notice that the signal handlers in postmaster.c do quite a lot of work,
> much more than what they teach you in school they should do.

Yes, they're pretty ugly.  However, we have not recently heard any
complaints suggesting problems with it.  Since we block signals
everywhere except just around the select() for new input, there's not
really any risk of recursive resource use AFAICS.

> ISTM that most of these, esp. pmdie(), can be written more like the SIGHUP
> handler, i.e., set a global variable and evaluate right after the
> select().

I would love to see it done that way, *if* you can show me a way to
guarantee that the signal response will happen promptly.  AFAIK there's
no portable way to ensure that we don't end up sitting and waiting for a
new client message before we get past the select().  If we could release
the signal mask just as an atomic part of the select operation, then
it'd work, but only some platforms support that.  This has been
discussed before, look in the archives.

SIGHUP is okay because we don't really care whether the postmaster
rereads the config file right away or only when it's about to process a
new request, anyhow.  But for other sorts of signals we need to be sure
that there can't be an indefinite delay before the signal is acted on.
        regards, tom lane


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Doing authentication in backend
Следующее
От: ncm@zembu.com (Nathan Myers)
Дата:
Сообщение: Re: What (not) to do in signal handlers