aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-10-16 12:54:23 -0700
committerChris Lu <chris.lu@gmail.com>2020-10-16 12:54:23 -0700
commit09bab17affc58a7b9c2c62a0b3af8712c08645d9 (patch)
tree86b5f8f613d67e8c15c48cbd16ada05e7c1afe42
parent9d80a3428c8ec9fa14dca45a5746ae32a458b8b6 (diff)
downloadseaweedfs-09bab17affc58a7b9c2c62a0b3af8712c08645d9.tar.xz
seaweedfs-09bab17affc58a7b9c2c62a0b3af8712c08645d9.zip
mount: avoid "send on closed channel"
-rw-r--r--weed/filesys/dirty_page.go20
-rw-r--r--weed/filesys/filehandle.go1
2 files changed, 14 insertions, 7 deletions
diff --git a/weed/filesys/dirty_page.go b/weed/filesys/dirty_page.go
index feaf8945b..a200050c4 100644
--- a/weed/filesys/dirty_page.go
+++ b/weed/filesys/dirty_page.go
@@ -10,13 +10,14 @@ import (
)
type ContinuousDirtyPages struct {
- intervals *ContinuousIntervals
- f *File
- writeWaitGroup sync.WaitGroup
- chunkSaveErrChan chan error
- lock sync.Mutex
- collection string
- replication string
+ intervals *ContinuousIntervals
+ f *File
+ writeWaitGroup sync.WaitGroup
+ chunkSaveErrChan chan error
+ chunkSaveErrChanClosed bool
+ lock sync.Mutex
+ collection string
+ replication string
}
func newDirtyPages(file *File) *ContinuousDirtyPages {
@@ -82,6 +83,11 @@ func (pages *ContinuousDirtyPages) saveExistingLargestPageToStorage() (hasSavedD
func (pages *ContinuousDirtyPages) saveToStorage(reader io.Reader, offset int64, size int64) {
+ if pages.chunkSaveErrChanClosed {
+ pages.chunkSaveErrChan = make(chan error, 8)
+ pages.chunkSaveErrChanClosed = false
+ }
+
mtime := time.Now().UnixNano()
pages.writeWaitGroup.Add(1)
go func() {
diff --git a/weed/filesys/filehandle.go b/weed/filesys/filehandle.go
index 687588788..01bca76f8 100644
--- a/weed/filesys/filehandle.go
+++ b/weed/filesys/filehandle.go
@@ -186,6 +186,7 @@ func (fh *FileHandle) Release(ctx context.Context, req *fuse.ReleaseRequest) err
}
// stop the goroutine
+ fh.dirtyPages.chunkSaveErrChanClosed = true
close(fh.dirtyPages.chunkSaveErrChan)
return nil