From 577a5618a1ee360328b1d8ee17a8ae0364da829d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Sun, 6 Mar 2022 18:09:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BA=AF=E5=86=85=E5=AD=98?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E5=8F=AF=E8=83=BD=E5=90=AF=E5=8A=A8=E5=A4=9A?= =?UTF-8?q?=E4=B8=AAflush=E5=86=85=E5=AE=B9=E7=9A=84goroutine=E7=9A=84Bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/caches/storage_memory.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/internal/caches/storage_memory.go b/internal/caches/storage_memory.go index aed851e..6ba0563 100644 --- a/internal/caches/storage_memory.go +++ b/internal/caches/storage_memory.go @@ -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) }