On 5/9/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
This is an interesting point, but I think a database might be more
similar to a network socket than a file handle.

I have this same observed behaviour under Oracle and PostgreSQL, so it's
not limited to mysql (and shouldn't be fixed with mysql specific flags).
snip

This is just to summarize what this thread was about.

The problem:

1. a process opens a database connection
2. does some work
3. forks a child that opens its own database connection
4. both run along with no problems
5. the child process ends
6. the parent's database connection is closed unexpectedly.

The reason:

The child has a copy of the parent's database handle.  When that
handle goes out of scope (because the program ended) it automagically*
closes.  This causes the databases to free the resources that are
still in use by the parent thus closing its handle unexpectedly.

The solution:

Setting a flag (InactiveDestroy) on the parent's handle inside the
child process prevents the automagic closing of the connection.

* the magic in this case is the DESTROY method of DBI::db

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to