Close iterators (#1542)

* Add Close() function to all the iterators

* Add defer iterator.Close() whenever we open an iterator

* Add isClosed to all iterators and panic/return error if used after closing

Co-authored-by: Svarog <feanorr@gmail.com>
This commit is contained in:
Elichai Turkel
2021-03-01 11:15:59 +02:00
committed by GitHub
parent 63b1d2a05a
commit 6a12428504
21 changed files with 222 additions and 8 deletions

View File

@@ -106,7 +106,8 @@ func (c *LevelDBCursor) Close() error {
return errors.New("cannot close an already closed cursor")
}
c.isClosed = true
c.ldbIterator.Release()
c.ldbIterator = nil
c.bucket = nil
return nil
}