Re: Transaction Wrapper and Perl 5.6.1
[prev]
[thread]
[next]
[Date index for 2004/09/02]
Tony Bowden wrote:
>On Wed, Sep 01, 2004 at 05:12:26PM -0500, Stuart Johnston wrote:
>
>
>>found out that "local $class->db_Main->{AutoCommit};" inside of
>>do_transaction() subroutine caused memory leaks with Perl 5.6.1 from
>>www.class-dbi.com site.
>>Unfortunately, I'm using Perl 5.6.1 and trying to find the way to solve
>>this issue without upgrading Perl.
>>Does anybody know how to solve this issue or what causes memory leaks?
>>
>>
>
>This was a bug in perl:
> http://www.mail-archive.com/dbi-announce@xxxx.xxx/msg00010.html
>
>Tony
>
>
Thanks Tony,
So.. I shouldn't worry about memory leaks when I don't use local on my
do_transaction code below written in Perl 5.6.1..?
sub do_transaction {
my ($class, $code, @args) = @_;
$class->_invalid_object_method('do_transaction()') if ref ($class);
$class->db_Main->{ AutoCommit } = 0;
my @return_values;
eval {
@return_values = $code->(@args);
$class->dbi_commit;
};
if ( $@ ) {
my $error = $@;
eval { $class->dbi_rollback; };
if ($@) {
my $rollback_error = $@;
$class->_croak("Transaction aborted; $error; ".
"Rollback failed: $rollback_error\n");
} else {
$class->_croak("Transaction aborted (rollback successful): $error\n");
}
}
$class->db_Main->{ AutoCommit } = 1;
return (@return_values);
}
Many many thanks..
-Young