mount: avoid "send on closed channel"

This commit is contained in:
Chris Lu
2020-10-16 12:54:23 -07:00
parent 9d80a3428c
commit 09bab17aff
2 changed files with 14 additions and 7 deletions

View File

@@ -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() {