Fix race.

This commit is contained in:
Nuno Cruces
2024-04-12 16:28:53 +01:00
parent da9077cbea
commit 4322c71a09

View File

@@ -59,6 +59,7 @@ type cursor struct {
base string
rowID int64
eof bool
open bool
}
type entry struct {
@@ -68,11 +69,10 @@ type entry struct {
}
func (c *cursor) Close() error {
if c.done != nil {
if c.open {
close(c.done)
s := <-c.next
c.done = nil
c.next = nil
c.open = false
return s.err
}
return nil
@@ -98,6 +98,7 @@ func (c *cursor) Filter(idxNum int, idxStr string, arg ...sqlite3.Value) error {
c.rowID = 0
c.eof = false
c.open = true
c.next = make(chan entry)
c.done = make(chan struct{})
go c.WalkDir(root)