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."

Reply via email to