Re: libpq enhancement for multi-process application

From: Sébastien Bonnet <bonseb(at)free(dot)fr>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Daniele Orlandi <daniele(at)orlandi(dot)com>
Subject: Re: libpq enhancement for multi-process application
Date: 2000-12-19 16:23:46
Message-ID: 3A3F8B92.124E4E3F@free.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> Uhm... I always thought that sharing the same socket between
> processes is wrong.

Well, I've never thought about it before this problem, but it definitely
appears to me like something not to do. Sharing remote object doesn't sound
right :-(

> My multi-process daemon works like apache with a pool of processes
> everyone with its own connection to the DB. The connection is only
> opened AFTER the fork and remains open as long as the process lives just
> to avoid a new connection for each accept.

When you can do it this way, that's nice'n'easy. In my case, I have to have a
connection before the fork, and keep it after in both parent and child,
eventhough it will be closed a few seconds later in the child. So, for now on,
the only-almost-clean-solution is to free the pgconn structure in the child
and reconnect when needed. This way, the parent process keeps its own
connexion. No other process is using it. Sounds safe, but kinda
"do-it-yourself" :-(

--
Sébastien Bonnet
bonseb(at)free(dot)fr http://bonseb.free.fr/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniele Orlandi 2000-12-19 17:10:10 Re: libpq enhancement for multi-process application
Previous Message Hiroshi Inoue 2000-12-19 15:41:15 Isn't init_irels() dangerous ?