pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
(no subject)
2+ messages / 2 participants
[nested] [flat]

* (no subject)
@ 2004-11-02 09:00  Einar Már Björvinsson <emb@media.is>
  0 siblings, 1 reply; 2+ messages in thread

From: Einar Már Björvinsson @ 2004-11-02 09:00 UTC (permalink / raw)
  To: pgsql-general

hi
I have been trying to use the Postgresql library (libpq.so) and processes in my program. 
The scenario is like that: 

I have made a small shared library where I wrapp the Postgresql functions. 

I then call those library functions (my library) from my program. 

The program is to behave as a deamon so it is in a endless while loop.

The program starts by opening a connection to the database, enter the infinite while loop to run some functions. 

Inside the while loop it forks many childs which then call one function from the library I made.

After one round the program goes to sleep and wakes up again one minute later. 

Now comes the problem:: If I call the same the same functions again, those within the while loop (not the connection call) I get an error return. 

It is as if the handle to the connection is not valid any more. 

I have checked the program without forking and that works fine.

So my question is what can be done to share a library within processes so they are not duplicating the library includes and so on.

regards

Einar

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re:
@ 2004-11-08 01:13  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Einar Már Björvinsson <emb@media.is>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2004-11-08 01:13 UTC (permalink / raw)
  To: Einar Már Björvinsson <emb@media.is>; +Cc: pgsql-general

=?iso-8859-1?Q?Einar_M=E1r_Bj=F6rvinsson?= <emb@media.is> writes:
> The program starts by opening a connection to the database, enter the =
> infinite while loop to run some functions.=20

> Inside the while loop it forks many childs which then call one function =
> from the library I made.

Are you trying to say that you are opening a database connection in the
parent process and passing it down for the children to play around with?
This is a fairly bad idea, unless you have an interlock mechanism to
ensure that only one child uses it at a time.

> It is as if the handle to the connection is not valid any more.=20

Perhaps the child is closing the connection when it's done with it.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2004-11-08 01:13 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-11-02 09:00  Einar Már Björvinsson <emb@media.is>
2004-11-08 01:13 ` Re: Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox