Konstantin Lebedev
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
10 additions and
4 deletions
-
weed/util/log_buffer/log_buffer.go
|
@ -118,6 +118,13 @@ func (m *LogBuffer) AddToBuffer(partitionKey, data []byte, processingTsNs int64) |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (m *LogBuffer) IsStopping() bool { |
|
|
|
|
|
m.RLock() |
|
|
|
|
|
defer m.RUnlock() |
|
|
|
|
|
|
|
|
|
|
|
return m.isStopping |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
func (m *LogBuffer) Shutdown() { |
|
|
func (m *LogBuffer) Shutdown() { |
|
|
m.Lock() |
|
|
m.Lock() |
|
|
defer m.Unlock() |
|
|
defer m.Unlock() |
|
@ -144,13 +151,12 @@ func (m *LogBuffer) loopFlush() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (m *LogBuffer) loopInterval() { |
|
|
func (m *LogBuffer) loopInterval() { |
|
|
for !m.isStopping { |
|
|
|
|
|
|
|
|
for !m.IsStopping() { |
|
|
time.Sleep(m.flushInterval) |
|
|
time.Sleep(m.flushInterval) |
|
|
m.Lock() |
|
|
|
|
|
if m.isStopping { |
|
|
|
|
|
m.Unlock() |
|
|
|
|
|
|
|
|
if m.IsStopping() { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
m.Lock() |
|
|
toFlush := m.copyToFlush() |
|
|
toFlush := m.copyToFlush() |
|
|
m.Unlock() |
|
|
m.Unlock() |
|
|
if toFlush != nil { |
|
|
if toFlush != nil { |
|
|