From 842d600e3faae31ead3ab97e70b8747f27c626b2 Mon Sep 17 00:00:00 2001 From: Derek Collison Date: Wed, 11 Oct 2023 07:54:36 -0700 Subject: [PATCH] Grab blk fn while mb lock held Signed-off-by: Derek Collison --- server/filestore.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/filestore.go b/server/filestore.go index 4621e5a8..54dd769c 100644 --- a/server/filestore.go +++ b/server/filestore.go @@ -4758,7 +4758,7 @@ func (fs *fileStore) syncBlocks() { } // Check if we need to sync. We will not hold lock during actual sync. - needSync := mb.needSync + needSync, fn := mb.needSync, mb.mfn if needSync { // Flush anything that may be pending. mb.flushPendingMsgsLocked() @@ -4768,7 +4768,7 @@ func (fs *fileStore) syncBlocks() { // Check if we need to sync. // This is done not holding any locks. if needSync { - if fd, _ := os.OpenFile(mb.mfn, os.O_RDWR, defaultFilePerms); fd != nil { + if fd, _ := os.OpenFile(fn, os.O_RDWR, defaultFilePerms); fd != nil { canClear := fd.Sync() == nil fd.Close() // Only clear sync flag on success.