From: rkinyon Date: Sat, 18 Feb 2006 12:52:31 +0000 (+0000) Subject: Added return values to lock()/unlock() and reinstated _close() X-Git-Tag: 0-97~43 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b4522594c8f2c7749acc89b94e4ceb32f250d6c6;p=dbsrgits%2FDBM-Deep.git Added return values to lock()/unlock() and reinstated _close() --- diff --git a/lib/DBM/Deep.pm b/lib/DBM/Deep.pm index beb015a..6c8e831 100644 --- a/lib/DBM/Deep.pm +++ b/lib/DBM/Deep.pm @@ -302,10 +302,8 @@ sub _close { ## # Close database FileHandle ## -# my $self = _get_self($_[0]); -# undef $self->root->{fh}; - #XXX Should it be this?? - #close $self->root->{fh}; + my $self = _get_self($_[0]); + close $self->root->{fh}; } sub _create_tag { @@ -919,7 +917,11 @@ sub lock { if ($self->root->{locking}) { if (!$self->root->{locked}) { flock($self->fh, $type); } $self->root->{locked}++; + + return 1; } + + return; } sub unlock { @@ -932,7 +934,11 @@ sub unlock { if ($self->root->{locking} && $self->root->{locked} > 0) { $self->root->{locked}--; if (!$self->root->{locked}) { flock($self->fh, LOCK_UN); } + + return 1; } + + return; } #XXX These uses of ref() need verified diff --git a/t/23_misc.t b/t/23_misc.t index e206ff3..343979a 100644 --- a/t/23_misc.t +++ b/t/23_misc.t @@ -32,7 +32,7 @@ throws_ok { } qr/^DBM::Deep: Signature not found -- file is not a Deep DB/, "Only DBM::Deep DB files will be opened"; TODO: { - todo_skip "lock() doesn't check to see if the file is open", 1; + local $TODO = "lock() doesn't check to see if the file is open"; my $db = DBM::Deep->new( file => 't/test.db', locking => 1, @@ -42,7 +42,7 @@ TODO: { } TODO: { - todo_skip "unlock() doesn't check to see if the file is open", 1; + local $TODO = "unlock() doesn't check to see if the file is open"; my $db = DBM::Deep->new( file => 't/test.db', locking => 1,