diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-03-01 12:53:05 -0700 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-03-01 12:53:05 -0700 |
commit | 3a1b152562a98de231f73e35c4df03994268328e (patch) | |
tree | f5ea028ad0f740234b4f8a54a6dc137259b84db1 /rwtransaction.go | |
parent | Merge pull request #57 from benbjohnson/node-aware-cursors (diff) | |
download | dedo-3a1b152562a98de231f73e35c4df03994268328e.tar.gz dedo-3a1b152562a98de231f73e35c4df03994268328e.tar.xz |
Ignore multiple transaction commit/rollback/close.
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. |