Commit 390ae7d9 authored by Steven Allen's avatar Steven Allen

fix: verify that the datastore is still open when querying

fixes part of https://github.com/ipfs/go-ipfs/issues/6986

(the other part is that we should be shutting down in the right order)
parent adacbc25
...@@ -342,6 +342,9 @@ func (d *Datastore) Delete(key ds.Key) error { ...@@ -342,6 +342,9 @@ func (d *Datastore) Delete(key ds.Key) error {
func (d *Datastore) Query(q dsq.Query) (dsq.Results, error) { func (d *Datastore) Query(q dsq.Query) (dsq.Results, error) {
d.closeLk.RLock() d.closeLk.RLock()
defer d.closeLk.RUnlock() defer d.closeLk.RUnlock()
if d.closed {
return nil, ErrClosed
}
txn := d.newImplicitTransaction(true) txn := d.newImplicitTransaction(true)
// We cannot defer txn.Discard() here, as the txn must remain active while the iterator is open. // We cannot defer txn.Discard() here, as the txn must remain active while the iterator is open.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment