PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

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
> process?

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
> allowed)

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
--
Michael Peppler         -||-  Data Migrations Inc.
mpeppler@datamig.com    -||-  http://www.mbay.net/~mpeppler
International Sybase    -||-  http://www.isug.com
User Group