On Wed, Jun 15, 2005 at 04:42:24PM -0400, Sam Tregar wrote:
> On Wed, 15 Jun 2005, Tim Bunce wrote:
>
> > Not currently. It would require the use of weak-refs to avoid
> > reference loops. (Patches welcome etc etc.)
>
> Alright, perhaps I'll take a swing at it.
Yeah! Thanks Sam.
Scratching itches is what makes the Open Source world go round.
> Can you suggest a good
> place to put the code to collect open handles? Knowing nothing about
> the internals I'm guessing connect() is the right spot.
Actually _new_handle() in DBI.pm
But first we need an API. A reasonable first draft would be to add a
$h->{ChildHandles} attribute that's a hash where the values of the hash
are the child handles. (The keys of the hash are irrelevant but unique.
The hash will have undef elements for any old handles that have been
destroyed so we'll need to prune them occasionally, but that can wait.)
So, given that API, you could start by trying something like this:
weaken($parent->{ChildHandles}{$h} = $h);
just after the call to DBI::_setup_handle($h, $imp_class, $parent, $imp_data);
You'll need a use Scalar::Util qw(weaken); at the top.
That's a basic hack that might work well enough for you to write some
tests that pass (add a new t/71childh.t test file).
Tim.
p.s. Followups to [email protected] please.