Skip to content

Commit 4322c71

Browse files
committed
Fix race.
1 parent da9077c commit 4322c71

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

ext/fileio/fsdir.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ type cursor struct {
5959
base string
6060
rowID int64
6161
eof bool
62+
open bool
6263
}
6364

6465
type entry struct {
@@ -68,11 +69,10 @@ type entry struct {
6869
}
6970

7071
func (c *cursor) Close() error {
71-
if c.done != nil {
72+
if c.open {
7273
close(c.done)
7374
s := <-c.next
74-
c.done = nil
75-
c.next = nil
75+
c.open = false
7676
return s.err
7777
}
7878
return nil
@@ -98,6 +98,7 @@ func (c *cursor) Filter(idxNum int, idxStr string, arg ...sqlite3.Value) error {
9898

9999
c.rowID = 0
100100
c.eof = false
101+
c.open = true
101102
c.next = make(chan entry)
102103
c.done = make(chan struct{})
103104
go c.WalkDir(root)

0 commit comments

Comments
 (0)