Re: Automatically managing inactiveDestroy property.



Sounds like you could just set InactiveDestroy on all handles by
default, but then turn it off in the parent process just before it
disconnects/exits.

You could also possibly play games overriding CORE::GLOBAL::fork()
and CORE::GLOBAL::system().

Tim.

On Mon, Mar 24, 2008 at 12:04:48PM -0400, Lenga, Yair wrote:
Hi,

I have a complex CGI program, which need to call external program, while
keeping the DBI connection open. I'm struggling with the
"InactiveDestroy" property. Per the DBI perldoc:

This attribute is specifically designed for use in Unix
applica-
tions that "fork" child processes. Either the parent or the
child
process, but not both, should set "InactiveDestroy" on all
their
shared handles. Note that some databases, including Oracle,
don't
support passing a database connection across a fork.

My problem is that I do not have any control over the interface to the
external program (3rd party perl code that I can not modify), which is
using both 'fork' and 'system'. In the past, I solved the problem using
the following method:
- Before calling the 3rd party library, the code will fork.
- The child will mark the inactiveDestroy.
- Code will call the 3rd party library
- Parent wait for child to complete.

This logic worked OK until I got extra requirements to store the results
of the 3rd party calls in the DB. Initially, I tried to push the results
from the child to the parent (using a pipe), but this is getting more
complex - as I requirement expanded to pass more data between the 3rd
party calls and the DB.

My questions/suggestion:
Will it make sense to manage the 'inactiveDestroy' automatically using
one of the following policies:

(A) Remember in the DBI handle the PID of the calling process, and
assume the 'InactiveDestroy' was turned on when the handle goes out of
scope on a process with a different PID (e.g, children). For me, this
solution will provide a clean handling of all the cases.

(B) Add a new property 'AutoInactiveDestroy' which will do the same. The
code will have to turn this property on (when the connection is created,
or before the fork).

I can not think of any situation where (A) will not work - but my
experience is limited to Linux/SunOS with Sybase/SQLITE/SQLServer.

Any feedback will be appreciated.

Regards,
Yair Lenga
.



Relevant Pages

  • Re: InactiveDestroy with Class::DBI
    ... Turning on InactiveDestroy in the child turns off the implicit call to disconnect from DESTROY for the inherited DB handle from the parent and thus should maintain the parent's connection. ...
    (perl.dbi.users)
  • Re: Embryos - sense prevails
    ... Or the party takes ... Or maybe the child is left with that man down the ... Abortion may only be legally performed ... Much as I would want to give men greater reasons not father children that they don't want, I wasn't seriously suggesting that forcing either parent to care for their children is a way to achieve this. ...
    (uk.legal)
  • Re: Roe v. Wade for Men?
    ... The man made the choice by fucking her in the first ... Once the child is born the two parties are equal, ... (In that case the other parent must still ... provide financial support unless the other party agrees to ...
    (rec.sport.football.college)
  • Re: b-day party ettiquette
    ... likely to come up since we appear to be about the only single child ... I have never seen a parent leave a party yet and DS is in first grade. ... most parents are just dropping kids off from ages 4 ...
    (misc.kids)
  • Re: b-day party ettiquette
    ... likely to come up since we appear to be about the only single child ... I have never seen a parent leave a party yet and DS is in first grade. ... most parents are just dropping kids off from ages 4 ...
    (misc.kids)