From 3a1b152562a98de231f73e35c4df03994268328e Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Sat, 1 Mar 2014 12:53:05 -0700 Subject: Ignore multiple transaction commit/rollback/close. --- rwtransaction.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'rwtransaction.go') diff --git a/rwtransaction.go b/rwtransaction.go index f47597f..776cf55 100644 --- a/rwtransaction.go +++ b/rwtransaction.go @@ -82,6 +82,10 @@ func (t *RWTransaction) DeleteBucket(name string) error { // Commit writes all changes to disk and updates the meta page. // Returns an error if a disk write error occurs. func (t *RWTransaction) Commit() error { + if t.db == nil { + return nil + } + defer t.close() // TODO(benbjohnson): Use vectorized I/O to write out dirty pages. @@ -119,7 +123,10 @@ func (t *RWTransaction) Rollback() { } func (t *RWTransaction) close() { - t.db.rwlock.Unlock() + if t.db != nil { + t.db.rwlock.Unlock() + t.db = nil + } } // allocate returns a contiguous block of memory starting at a given page. -- cgit v1.2.3