修复纯内存缓存可能启动多个flush内容的goroutine的Bug

This commit is contained in:
刘祥超
2022-03-06 18:09:33 +08:00
parent 49822ab7e9
commit 577a5618a1

View File

@@ -99,11 +99,13 @@ func (this *MemoryStorage) Init() error {
})
// 启动定时Flush memory to disk任务
goman.New(func() {
for hash := range this.dirtyChan {
this.flushItem(hash)
}
})
if this.parentStorage != nil {
goman.New(func() {
for hash := range this.dirtyChan {
this.flushItem(hash)
}
})
}
return nil
}
@@ -277,7 +279,7 @@ func (this *MemoryStorage) Stop() {
this.purgeTicker.Stop()
}
if this.parentStorage != nil && this.dirtyChan != nil {
if this.dirtyChan != nil {
close(this.dirtyChan)
}