From 77b7c9f7ccce5ac9e4b0cb22b6018e5758a4c380 Mon Sep 17 00:00:00 2001 From: chrislu Date: Wed, 21 Dec 2022 14:15:35 -0800 Subject: [PATCH] lock and unlock chunks for read --- weed/mount/page_writer/upload_pipeline_lock.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/weed/mount/page_writer/upload_pipeline_lock.go b/weed/mount/page_writer/upload_pipeline_lock.go index 43b04e01d..fec61b532 100644 --- a/weed/mount/page_writer/upload_pipeline_lock.go +++ b/weed/mount/page_writer/upload_pipeline_lock.go @@ -10,6 +10,8 @@ func (up *UploadPipeline) LockForRead(startOffset, stopOffset int64) { if stopOffset%up.ChunkSize > 0 { stopLogicChunkIndex += 1 } + up.chunksLock.Lock() + defer up.chunksLock.Unlock() for i := startLogicChunkIndex; i < stopLogicChunkIndex; i++ { if count, found := up.activeReadChunks[i]; found { up.activeReadChunks[i] = count + 1 @@ -25,6 +27,8 @@ func (up *UploadPipeline) UnlockForRead(startOffset, stopOffset int64) { if stopOffset%up.ChunkSize > 0 { stopLogicChunkIndex += 1 } + up.chunksLock.Lock() + defer up.chunksLock.Unlock() for i := startLogicChunkIndex; i < stopLogicChunkIndex; i++ { if count, found := up.activeReadChunks[i]; found { if count == 1 {