From 42f6a3679f70d987222a163ef1514f6b90287430 Mon Sep 17 00:00:00 2001 From: siddontang Date: Thu, 4 Sep 2014 14:55:26 +0800 Subject: [PATCH] bugfix for lmdb --- store/mdb/mdb.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/store/mdb/mdb.go b/store/mdb/mdb.go index 171c088..d5c3987 100644 --- a/store/mdb/mdb.go +++ b/store/mdb/mdb.go @@ -92,14 +92,16 @@ func (s Store) Repair(path string, c *config.Config) error { func (db MDB) Put(key, value []byte) error { itr := db.iterator(false) + defer itr.Close() itr.err = itr.c.Put(key, value, 0) itr.setState() - return itr.Close() + return itr.err } func (db MDB) BatchPut(writes []driver.Write) error { itr := db.iterator(false) + defer itr.Close() for _, w := range writes { if w.Value == nil { @@ -117,7 +119,7 @@ func (db MDB) BatchPut(writes []driver.Write) error { } itr.setState() - return itr.Close() + return itr.err } func (db MDB) Get(key []byte) ([]byte, error) { @@ -208,6 +210,8 @@ func (itr *MDBIterator) setState() { itr.err = nil } itr.valid = false + } else { + itr.valid = true } }