Given that, ALL children threads from a fork inherit the attributes of the
parent, when you issue the undef from within the child, with a named
handle, from the parent, it's likely that this disconnects that handle and
ALL sibling threads also have the same, disconnected view.
When I was programming IPC channels, forks in UNIX for
synchronous/asynchronous communication, that's exactly how they behaved.
The $dbh from each of your child threads and parent see $dbh the same way.
Again, because $dbh is a parent thread variable, it is inherited to each
spawned thread.
On Mon, 7 Nov 2005, Jonathan Leffler wrote:
On 11/6/05, Aaron Turner <[EMAIL PROTECTED]> wrote:
Can you explain why you think that?
It's is the normal source of trouble when someone mentions fork and failure.
I didn't scrutinize your code - if I missed something obvious, I apologize
for casting aspersions.
When I run my code, I see the
$dbh hash change inside of the child process and the parent hash stay
the same. Aren't I avoiding using the same handle by doing a $dbh =
undef in the child and then calling connect again?
The undef probably does the damage - the connect again would be correct.
If the 'undef' causes the child process to disconnect, then it closes the
connection and the server is none the wiser that it was only one of two
processes that closed the connection.
On Nov 5, 2005, at 9:56 PM, Jonathan Leffler wrote:
On 11/5/05, Aaron Turner <[EMAIL PROTECTED]> wrote:
So I'm trying to track down a problem with my program which forks
needing both parent and children to have access to the database via
Class::DBI. The basic issue I'm having is that after the first child
exits, the parent's DBI connection seems to get mangled, because it
can no longer find the prepared statements created by Class::DBI.
[...]
So, the DBI manual says words to the effect of "don't try reusing
handles in
child processes - it usually won't work", and your code seems to be
demonstrating exactly that.
Each process that needs to connect to a database needs to connect
separately.
--
Jonathan Leffler <[EMAIL PROTECTED]> #include <disclaimer.h>
Guardian of DBD::Informix - v2005.02 - http://dbi.perl.org
"I don't suffer from insanity - I enjoy every minute of it."
--
/********** Louis Gonzales ***********\
/****** http://www.linuxlouis.net ****\
/**** [EMAIL PROTECTED] **\
/****** HP Certified Professional ****\