Up Prev Next
From: Michael Peppler <mpeppler at MBAY dot NET>
Subject: Re: Passing a connection across a fork()
Date: Feb 23 1998 4:08PM
Alex Rolfe wrote:
> My questions are:
> 1) Is is safe to pass a database connection through a fork or am I just
> getting lucky?
It is NOT safe if it's the same physical connection and the child
processes might use it simultaneously. It's fine to open a new
connection in the parent and pass it to the child, however.
> 2) How would I disable the connection closing for all but the parent
This is already the case (unless you've hit on a bug, but I doubt it).
As others have pointed out, you may have it the 'trying to run a new
command with results pending' message, which will happen if one
child tries to start a database command while another is still
fetching results from a previous command.
> The alternatives are
> - to open a number of database connections and give one to each child
> (though this assumes that passing a connection through a fork is
That should work fine.
> - to start multiple daemons on multiple ports and let the front end try
> to find a free one.
That would be a bit of a pain...
Michael Peppler -||- Data Migrations Inc.
email@example.com -||- http://www.mbay.net/~mpeppler
International Sybase -||- http://www.isug.com