Skip to content

Commit

Permalink
fix: verify that the datastore is still open when querying
Browse files Browse the repository at this point in the history
fixes part of ipfs/kubo#6986

(the other part is that we should be shutting down in the right order)
  • Loading branch information
Stebalien committed Apr 16, 2020
1 parent b22f0b5 commit 5d26f37
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,9 @@ func (d *Datastore) Delete(key ds.Key) error {
func (d *Datastore) Query(q dsq.Query) (dsq.Results, error) {
d.closeLk.RLock()
defer d.closeLk.RUnlock()
if d.closed {
return nil, ErrClosed
}

txn := d.newImplicitTransaction(true)
// We cannot defer txn.Discard() here, as the txn must remain active while the iterator is open.
Expand Down

0 comments on commit 5d26f37

Please sign in to comment.