diff --git a/server/filestore.go b/server/filestore.go index 3eb0ba49..fd602af0 100644 --- a/server/filestore.go +++ b/server/filestore.go @@ -118,6 +118,7 @@ type msgBlock struct { fch chan struct{} qch chan struct{} lchk [8]byte + closed bool } // Write through caching layer that is also used on loading messages. @@ -3176,9 +3177,10 @@ func (mb *msgBlock) close(sync bool) { mb.mu.Lock() defer mb.mu.Unlock() - if mb.qch == nil { + if mb.closed { return } + mb.closed = true // Close cache mb.clearCacheAndOffset() diff --git a/server/test_test.go b/server/test_test.go index 6928e33d..3863f688 100644 --- a/server/test_test.go +++ b/server/test_test.go @@ -182,13 +182,14 @@ func (c *cluster) shutdown() { return } for i, s := range c.servers { + sd := s.StoreDir() + s.Shutdown() if cf := c.opts[i].ConfigFile; cf != "" { os.RemoveAll(cf) } - if sd := s.StoreDir(); sd != "" { + if sd != _EMPTY_ { os.RemoveAll(sd) } - s.Shutdown() } }