Re: Using connection after fork

Поиск
Список
Период
Сортировка
От Jeff
Тема Re: Using connection after fork
Дата
Msg-id 9A359E04-EAD6-11D8-86DE-000393D1F76E@torgo.978.org
обсуждение исходный текст
Ответ на Using connection after fork  (Peter Eisentraut <peter_e@gmx.net>)
Ответы Re: Using connection after fork  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
On Aug 10, 2004, at 4:41 AM, Peter Eisentraut wrote:

> does the following:  A daemon process opens a database connection,
> forks
> children on request, and those children access the database using that
> inherited connection.  After one request, the child dies.  It seems to
> me

I've been bit by this sort of thing before.  When you fork() the child
inherits all the file descriptors , including the one connected to PG.
But when the child dies  that FD will be closed, thus it will also be
closed in the parent causing "odd behavior".   (At least, that is what
I've seen in my apps)

> that this connection sharing cannot work because the processes would
> get
> mixed up, but the author claims that he has tested this successfully.
> I've
> been trying to figure out the semantics from the libc documentation,
> but I
> can't find a definitive answer.  Does anyone know what will happen in
> this
> situation, and why it actually appears to work?
>

Does it work for sustained periods of time?  Is the parent reconnecting
to PG after each child dies?  It *shouldn't* work.


--
Jeff Trout <jeff@jefftrout.com>
http://www.jefftrout.com/
http://www.stuarthamm.net/


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

Предыдущее
От: Raphael Bauduin
Дата:
Сообщение: Re: history tables with only one function?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Using connection after fork