Обсуждение: Dangerous code in syslogger?

Поиск
Список
Период
Сортировка

Dangerous code in syslogger?

От
"Magnus Hagander"
Дата:
I'm trying to track down a problem with socket inheritance and the
syslogger, and I noticed something that I think is very dangerous code:
The function pipeThread() is called on a non-default thread, and yet
uses ereport(). ereport() is, AFAIK, not thread-safe. Am I mistaken
here, or is this a crash waiting to happen?

//Magnus


Re: Dangerous code in syslogger?

От
Tom Lane
Дата:
"Magnus Hagander" <mha@sollentuna.net> writes:
> I'm trying to track down a problem with socket inheritance and the
> syslogger, and I noticed something that I think is very dangerous code:
> The function pipeThread() is called on a non-default thread, and yet
> uses ereport(). ereport() is, AFAIK, not thread-safe. Am I mistaken
> here, or is this a crash waiting to happen?

I think you're right.  Might be best to restructure the locking so that
rather than protecting only access to syslogFile, the data transfer
thread holds the lock whenever it's not doing ReadFile() from the pipe,
and the main thread likewise holds the lock except when sleeping.

            regards, tom lane