Re: Passing a PGconn * between two processes on Unix like systems

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Marc Balmer <marc(at)msys(dot)ch>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Passing a PGconn * between two processes on Unix like systems
Date: 2010-07-22 08:56:30
Message-ID: AANLkTim7OkpxBAG-1J6kdd1QdI-ci7T8RvqLa_vGYpe3@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Jul 22, 2010 at 08:35, Marc Balmer <marc(at)msys(dot)ch> wrote:
> I two Unix/ process related questions:
>
> Is there a documented way to pass around an (opened) PGconn * structure
> between two processes on Unix?

No.

You can probably hack up something yourself but you'd have to look
inside the struct which is not part of the public API - so it'd be a
very version-dependent (even minor-version dependent!) hack.

> When a process forks() and both the parent and child process continue to
> use a previously opened PGconn * structure, is that behaviour defined?

Yes - "broken" :-)

Well, the child can continue to use it *as long as the parent doesn't
use it anymore*.

And note that while it may be a good idea in general to close the
socket in the parent, you can *not* call PQclose() on it - that'll
tell the server you're disconnecting, and the child will stop working.
In theory you could do something like close(PQsocket(conn))...

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Oliver Kohll - Mailing Lists 2010-07-22 09:02:47 Re: locating cities within a radius of another
Previous Message Devrim GÜNDÜZ 2010-07-22 07:54:44 Re: Finding last checkpoint time