mirror of
https://github.com/chrislusf/seaweedfs
synced 2024-06-03 01:00:04 +02:00
Fixes unlocked read from logBuffer.LastTsNs that is racey. (#5536)
This commit is contained in:
parent
855607c536
commit
abf01a0eb7
|
@ -66,9 +66,17 @@ func (logBuffer *LogBuffer) LoopProcessLogData(readerName string, startPosition
|
||||||
isDone = true
|
isDone = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
logBuffer.RLock()
|
||||||
lastTsNs := logBuffer.LastTsNs
|
lastTsNs := logBuffer.LastTsNs
|
||||||
for lastTsNs == logBuffer.LastTsNs {
|
logBuffer.RUnlock()
|
||||||
|
loopTsNs := lastTsNs // make a copy
|
||||||
|
|
||||||
|
for lastTsNs == loopTsNs {
|
||||||
if waitForDataFn() {
|
if waitForDataFn() {
|
||||||
|
// Update loopTsNs and loop again
|
||||||
|
logBuffer.RLock()
|
||||||
|
loopTsNs = logBuffer.LastTsNs
|
||||||
|
logBuffer.RUnlock()
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
isDone = true
|
isDone = true
|
||||||
|
|
Loading…
Reference in a new issue