Commit 7572e9d8 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

nodefs: protect dirsteam overflow with lock

Appeases the race detector.
parent 623db2fc
......@@ -27,6 +27,8 @@ type fileEntry struct {
// Directory
dirStream DirStream
mu sync.Mutex
hasOverflow bool
overflow fuse.DirEntry
......@@ -833,16 +835,20 @@ func (b *rawBridge) ReadDirPlus(cancel <-chan struct{}, input *fuse.ReadIn, out
if errno := b.setStream(cancel, input, n, f); errno != 0 {
return errnoToStatus(errno)
}
ctx := &fuse.Context{Caller: input.Caller, Cancel: cancel}
for f.dirStream.HasNext() {
var e fuse.DirEntry
var errno syscall.Errno
f.mu.Lock()
if f.hasOverflow {
e = f.overflow
f.hasOverflow = false
} else {
e, errno = f.dirStream.Next()
}
f.mu.Unlock()
if errno != 0 {
return errnoToStatus(errno)
......@@ -850,8 +856,10 @@ func (b *rawBridge) ReadDirPlus(cancel <-chan struct{}, input *fuse.ReadIn, out
entryOut := out.AddDirLookupEntry(e)
if entryOut == nil {
f.mu.Lock()
f.overflow = e
f.hasOverflow = true
f.mu.Unlock()
return fuse.OK
}
......
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