From a9662d44ace94d191a90cc0893021db2f172f902 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 2 Nov 2020 14:20:38 -0800 Subject: [PATCH] avoid closing chunkSaveErrChan too early --- weed/filesys/filehandle.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/weed/filesys/filehandle.go b/weed/filesys/filehandle.go index 54bde3494..1fbeeb4dc 100644 --- a/weed/filesys/filehandle.go +++ b/weed/filesys/filehandle.go @@ -183,17 +183,20 @@ func (fh *FileHandle) Release(ctx context.Context, req *fuse.ReleaseRequest) err } if fh.f.isOpen == 0 { + if err := fh.doFlush(ctx, req.Header); err != nil { glog.Errorf("Release doFlush %s: %v", fh.f.Name, err) } + + // stop the goroutine + if !fh.dirtyPages.chunkSaveErrChanClosed { + fh.dirtyPages.chunkSaveErrChanClosed = true + close(fh.dirtyPages.chunkSaveErrChan) + } + fh.f.wfs.ReleaseHandle(fh.f.fullpath(), fuse.HandleID(fh.handle)) } - // stop the goroutine - if !fh.dirtyPages.chunkSaveErrChanClosed { - fh.dirtyPages.chunkSaveErrChanClosed = true - close(fh.dirtyPages.chunkSaveErrChan) - } return nil }