From: rkinyon@cpan.org Date: Tue, 1 Jul 2008 01:26:16 +0000 (+0000) Subject: Fixed why t/33 was failing (errors were skipping the unlock, thus blocking further... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c65299b4ded14190b42c2b2710db9a7a90158465;p=dbsrgits%2FDBM-Deep.git Fixed why t/33 was failing (errors were skipping the unlock, thus blocking further commands git-svn-id: http://svn.ali.as/cpan/trunk/DBM-Deep@3671 88f4d9cd-8a04-0410-9d60-8f63309c3137 --- diff --git a/lib/DBM/Deep.pm b/lib/DBM/Deep.pm index 24056e4..1defc2b 100644 --- a/lib/DBM/Deep.pm +++ b/lib/DBM/Deep.pm @@ -420,24 +420,30 @@ sub clone { sub begin_work { my $self = shift->_get_self; $self->lock_exclusive; - my $rv = $self->_engine->begin_work( $self, @_ ); + my $rv = eval { $self->_engine->begin_work( $self, @_ ) }; + my $e = $@; $self->unlock; + die $e if $e; return $rv; } sub rollback { my $self = shift->_get_self; $self->lock_exclusive; - my $rv = $self->_engine->rollback( $self, @_ ); + my $rv = eval { $self->_engine->rollback( $self, @_ ) }; + my $e = $@; $self->unlock; + die $e if $e; return $rv; } sub commit { my $self = shift->_get_self; $self->lock_exclusive; - my $rv = $self->_engine->commit( $self, @_ ); + my $rv = eval { $self->_engine->commit( $self, @_ ) }; + my $e = $@; $self->unlock; + die $e if $e; return $rv; } diff --git a/lib/DBM/Deep/Engine.pm b/lib/DBM/Deep/Engine.pm index 870a528..85cdafe 100644 --- a/lib/DBM/Deep/Engine.pm +++ b/lib/DBM/Deep/Engine.pm @@ -496,27 +496,6 @@ sub rollback { $self->_load_sector( $sector )->rollback( $idx ); } -=pod - # Each entry is the file location for a bucket that has a modification for - # this transaction. The entries need to be expunged. - foreach my $entry (@{ $self->get_entries } ) { - # Remove the entry here - my $read_loc = $entry - + $self->hash_size - + $self->byte_size - + $self->byte_size - + ($self->trans_id - 1) * ( $self->byte_size + $STALE_SIZE ); - - my $data_loc = $self->storage->read_at( $read_loc, $self->byte_size ); - $data_loc = unpack( $StP{$self->byte_size}, $data_loc ); - $self->storage->print_at( $read_loc, pack( $StP{$self->byte_size}, 0 ) ); - - if ( $data_loc > 1 ) { - $self->_load_sector( $data_loc )->free; - } - } -=cut - $self->clear_entries; my @slots = $self->read_txn_slots; @@ -541,33 +520,6 @@ sub commit { $self->_load_sector( $sector )->commit( $idx ); } -=pod - foreach my $entry (@{ $self->get_entries } ) { - # Overwrite the entry in head with the entry in trans_id - my $base = $entry - + $self->hash_size - + $self->byte_size; - - my $head_loc = $self->storage->read_at( $base, $self->byte_size ); - $head_loc = unpack( $StP{$self->byte_size}, $head_loc ); - - my $spot = $base + $self->byte_size + ($self->trans_id - 1) * ( $self->byte_size + $STALE_SIZE ); - my $trans_loc = $self->storage->read_at( - $spot, $self->byte_size, - ); - - $self->storage->print_at( $base, $trans_loc ); - $self->storage->print_at( - $spot, - pack( $StP{$self->byte_size} . ' ' . $StP{$STALE_SIZE}, (0) x 2 ), - ); - - if ( $head_loc > 1 ) { - $self->_load_sector( $head_loc )->free; - } - } -=cut - $self->clear_entries; my @slots = $self->read_txn_slots; diff --git a/t/33_transactions.t b/t/33_transactions.t index 49252ad..1055952 100644 --- a/t/33_transactions.t +++ b/t/33_transactions.t @@ -47,10 +47,7 @@ lives_ok { } "Rolling back an empty transaction is ok."; cmp_bag( [ keys %$db1 ], [qw( x )], "DB1 keys correct" ); -__END__ -warn "4\n"; cmp_bag( [ keys %$db2 ], [qw( x )], "DB2 keys correct" ); -warn "5\n"; $db1->begin_work;