Commit d5a1bca6 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

nodefs: close dirstream on Releasedir

parent 1002f0a1
...@@ -75,7 +75,7 @@ type DirStream interface { ...@@ -75,7 +75,7 @@ type DirStream interface {
Next() (fuse.DirEntry, fuse.Status) Next() (fuse.DirEntry, fuse.Status)
// Close releases resources related to this directory // Close releases resources related to this directory
// stream. A stream should be resilient against double close. // stream.
Close() Close()
} }
......
...@@ -492,6 +492,11 @@ func (b *rawBridge) Release(input *fuse.ReleaseIn) { ...@@ -492,6 +492,11 @@ func (b *rawBridge) Release(input *fuse.ReleaseIn) {
} }
func (b *rawBridge) ReleaseDir(input *fuse.ReleaseIn) { func (b *rawBridge) ReleaseDir(input *fuse.ReleaseIn) {
_, f := b.inode(input.NodeId, input.Fh)
if f.dirStream != nil {
f.dirStream.Close()
}
b.releaseFileEntry(input.Fh) b.releaseFileEntry(input.Fh)
} }
...@@ -540,6 +545,7 @@ func (b *rawBridge) getStream(input *fuse.ReadIn, inode *Inode, f *fileEntry) fu ...@@ -540,6 +545,7 @@ func (b *rawBridge) getStream(input *fuse.ReadIn, inode *Inode, f *fileEntry) fu
if f.dirStream == nil || input.Offset == 0 { if f.dirStream == nil || input.Offset == 0 {
if f.dirStream != nil { if f.dirStream != nil {
f.dirStream.Close() f.dirStream.Close()
f.dirStream = nil
} }
str, code := inode.node.ReadDir(context.TODO()) str, code := inode.node.ReadDir(context.TODO())
if !code.Ok() { if !code.Ok() {
...@@ -571,7 +577,6 @@ func (b *rawBridge) ReadDir(input *fuse.ReadIn, out *fuse.DirEntryList) fuse.Sta ...@@ -571,7 +577,6 @@ func (b *rawBridge) ReadDir(input *fuse.ReadIn, out *fuse.DirEntryList) fuse.Sta
e, code := f.dirStream.Next() e, code := f.dirStream.Next()
if !code.Ok() { if !code.Ok() {
f.dirStream.Close()
return code return code
} }
if !out.AddDirEntry(e) { if !out.AddDirEntry(e) {
...@@ -581,7 +586,6 @@ func (b *rawBridge) ReadDir(input *fuse.ReadIn, out *fuse.DirEntryList) fuse.Sta ...@@ -581,7 +586,6 @@ func (b *rawBridge) ReadDir(input *fuse.ReadIn, out *fuse.DirEntryList) fuse.Sta
} }
} }
f.dirStream.Close()
return fuse.OK return fuse.OK
} }
...@@ -609,7 +613,6 @@ func (b *rawBridge) ReadDirPlus(input *fuse.ReadIn, out *fuse.DirEntryList) fuse ...@@ -609,7 +613,6 @@ func (b *rawBridge) ReadDirPlus(input *fuse.ReadIn, out *fuse.DirEntryList) fuse
} }
if !code.Ok() { if !code.Ok() {
f.dirStream.Close()
return code return code
} }
...@@ -637,7 +640,6 @@ func (b *rawBridge) ReadDirPlus(input *fuse.ReadIn, out *fuse.DirEntryList) fuse ...@@ -637,7 +640,6 @@ func (b *rawBridge) ReadDirPlus(input *fuse.ReadIn, out *fuse.DirEntryList) fuse
} }
} }
f.dirStream.Close()
return fuse.OK 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