mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
lock and unlock chunks for read
This commit is contained in:
parent
d1797deccb
commit
77b7c9f7cc
|
@ -10,6 +10,8 @@ func (up *UploadPipeline) LockForRead(startOffset, stopOffset int64) {
|
||||||
if stopOffset%up.ChunkSize > 0 {
|
if stopOffset%up.ChunkSize > 0 {
|
||||||
stopLogicChunkIndex += 1
|
stopLogicChunkIndex += 1
|
||||||
}
|
}
|
||||||
|
up.chunksLock.Lock()
|
||||||
|
defer up.chunksLock.Unlock()
|
||||||
for i := startLogicChunkIndex; i < stopLogicChunkIndex; i++ {
|
for i := startLogicChunkIndex; i < stopLogicChunkIndex; i++ {
|
||||||
if count, found := up.activeReadChunks[i]; found {
|
if count, found := up.activeReadChunks[i]; found {
|
||||||
up.activeReadChunks[i] = count + 1
|
up.activeReadChunks[i] = count + 1
|
||||||
|
@ -25,6 +27,8 @@ func (up *UploadPipeline) UnlockForRead(startOffset, stopOffset int64) {
|
||||||
if stopOffset%up.ChunkSize > 0 {
|
if stopOffset%up.ChunkSize > 0 {
|
||||||
stopLogicChunkIndex += 1
|
stopLogicChunkIndex += 1
|
||||||
}
|
}
|
||||||
|
up.chunksLock.Lock()
|
||||||
|
defer up.chunksLock.Unlock()
|
||||||
for i := startLogicChunkIndex; i < stopLogicChunkIndex; i++ {
|
for i := startLogicChunkIndex; i < stopLogicChunkIndex; i++ {
|
||||||
if count, found := up.activeReadChunks[i]; found {
|
if count, found := up.activeReadChunks[i]; found {
|
||||||
if count == 1 {
|
if count == 1 {
|
||||||
|
|
Loading…
Reference in a new issue