Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: scope and undef

by bart (Canon)
on Aug 28, 2007 at 10:39 UTC ( [id://635559]=note: print w/replies, xml ) Need Help??


in reply to scope and undef

VC has a point, it might involve a circular reference, the phrase "a call to create a database object (which creates the db connection) and assigns it to $self->{dbo}" surely sound circular-referency. Could you try using delete instead of undef? Maybe it helps.

However, deep in my heart, I don't really believe it, this has the fault smell of a bug in Perl.

For debugging purposes, to see if any attempt is being made to clean up the object, you can add print statements in a DESTROY handler — use Hook::LexWrap or another similar module if one already exists and you don't want to edit the source; or subclass the class of the database connection.

Replies are listed 'Best First'.
Re^2: scope and undef
by Ryszard (Priest) on Aug 28, 2007 at 13:19 UTC
    cool bart, and thanks for the reply. I'll show a bit more detail into what i'm doing which hopefully will make what i see with Hook::LexWrap a little clearer to you.
    my $app = Daemon->new(sleep => 60, mailLimit => 200); while (1) { $app->mailout(); print scalar(localtime)." Sleeping 300 seconds...\n"; sleep 10; }

    is how the Daemon is called.

    inside Daemon is a call to an object i've made myself to manage database connections, which you can find here, which is not particularly complicated, or fancy, just an abstraction to the DBI which i find handy. we'll call this DBhandler. on creating a Daemon object, DBhandler is put into $self->{dbo}

    Since Daemon is persistant, i wrapped DESTROY in DBhandler, and told it to print Dumper($self).

    This is where i see things that are contradictory. when i undef $self->{dbo} DESTROY is called in DBhandler, and i see $self being dumped to standard out, however upon checking the sessions in the database (ie via v$session) i see the number of connections from that user increasing!

    oh, for the record, the delete, while not tested in this specific context, (ie with Hook::LexWrap), symptoms are the same.

      In that code you do a foreach on a hashref. I don't think that destroy is actualy looping at all. Shouldn't it be foreach (keys %{$self->{_db_handle}})?

      sub DESTROY { my $self = shift; foreach ($self->{_db_handle}) { $self->{_db_handle}{$_}->disconnect; } }

      ___________
      Eric Hodges
        You're right there, its a bug in the code. I've actually fixed that in the one that i'm using (but have neglected to update the version here.. )

        well spotted! :-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://635559]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2024-03-28 09:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found