From 72e1aff237511fff72e1455e1b31b1f55e6d0ceb Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Wed, 22 Jan 2020 15:38:25 -0800 Subject: [PATCH] add lock on dirty pages --- weed/filesys/dirty_page.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/weed/filesys/dirty_page.go b/weed/filesys/dirty_page.go index 7a466b506..3418dc1c9 100644 --- a/weed/filesys/dirty_page.go +++ b/weed/filesys/dirty_page.go @@ -231,6 +231,10 @@ func min(x, y int64) int64 { func (pages *ContinuousDirtyPages) ReadDirtyData(ctx context.Context, data []byte, startOffset int64) (offset int64, size int, err error) { bufSize := int64(len(data)) + + pages.lock.Lock() + defer pages.lock.Unlock() + if startOffset+bufSize < pages.Offset { return }