Browse Source
Fixes unlocked read from logBuffer.LastTsNs that is racey. (#5536)
pull/5539/head
M@
8 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
9 additions and
1 deletions
-
weed/util/log_buffer/log_read.go
|
|
@ -66,9 +66,17 @@ func (logBuffer *LogBuffer) LoopProcessLogData(readerName string, startPosition |
|
|
|
isDone = true |
|
|
|
return |
|
|
|
} |
|
|
|
logBuffer.RLock() |
|
|
|
lastTsNs := logBuffer.LastTsNs |
|
|
|
for lastTsNs == logBuffer.LastTsNs { |
|
|
|
logBuffer.RUnlock() |
|
|
|
loopTsNs := lastTsNs // make a copy
|
|
|
|
|
|
|
|
for lastTsNs == loopTsNs { |
|
|
|
if waitForDataFn() { |
|
|
|
// Update loopTsNs and loop again
|
|
|
|
logBuffer.RLock() |
|
|
|
loopTsNs = logBuffer.LastTsNs |
|
|
|
logBuffer.RUnlock() |
|
|
|
continue |
|
|
|
} else { |
|
|
|
isDone = true |
|
|
|