begin_work, rollback, and commit now properly lock the database
[dbsrgits/DBM-Deep.git] / lib / DBM / Deep.pm
index 56ecc0c..24056e4 100644 (file)
@@ -82,6 +82,8 @@ sub DESTROY {
     # If we have an error, don't flush - we might be flushing bad stuff. -RobK, 2008-06-26
     die $@ if $@;
 
+    #XXX For some reason, this causes an allocation error in the final scope close
+    # of t/08_deephash.t. -RobK, 2008-06-28
     $self->_get_self->_engine->flush;
 }
 
@@ -417,17 +419,26 @@ sub clone {
 
 sub begin_work {
     my $self = shift->_get_self;
-    return $self->_engine->begin_work( $self, @_ );
+    $self->lock_exclusive;
+    my $rv = $self->_engine->begin_work( $self, @_ );
+    $self->unlock;
+    return $rv;
 }
 
 sub rollback {
     my $self = shift->_get_self;
-    return $self->_engine->rollback( $self, @_ );
+    $self->lock_exclusive;
+    my $rv = $self->_engine->rollback( $self, @_ );
+    $self->unlock;
+    return $rv;
 }
 
 sub commit {
     my $self = shift->_get_self;
-    return $self->_engine->commit( $self, @_ );
+    $self->lock_exclusive;
+    my $rv = $self->_engine->commit( $self, @_ );
+    $self->unlock;
+    return $rv;
 }
 
 ##