diff options
Diffstat (limited to 'rwtransaction.go')
-rw-r--r-- | rwtransaction.go | 9 |
1 files changed, 8 insertions, 1 deletions
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. |