mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-12-27 07:39:05 +01:00
Fix: Corrected unlock access to batch slice
This commit is contained in:
parent
dd40c852ca
commit
3be11984f2
@ -155,7 +155,6 @@ func (s *InfluxSink) connect() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *InfluxSink) Write(m lp.CCMetric) error {
|
func (s *InfluxSink) Write(m lp.CCMetric) error {
|
||||||
|
|
||||||
if s.flushDelay != 0 && s.flushTimerMutex.TryLock() {
|
if s.flushDelay != 0 && s.flushTimerMutex.TryLock() {
|
||||||
|
|
||||||
// Setup flush timer when flush delay is configured
|
// Setup flush timer when flush delay is configured
|
||||||
@ -183,7 +182,6 @@ func (s *InfluxSink) Write(m lp.CCMetric) error {
|
|||||||
|
|
||||||
// Protect access to batch slice
|
// Protect access to batch slice
|
||||||
s.batchMutex.Lock()
|
s.batchMutex.Lock()
|
||||||
defer s.batchMutex.Unlock()
|
|
||||||
|
|
||||||
// batch slice full, dropping oldest metric(s)
|
// batch slice full, dropping oldest metric(s)
|
||||||
// e.g. when previous flushes failed and batch slice was not cleared
|
// e.g. when previous flushes failed and batch slice was not cleared
|
||||||
@ -259,6 +257,9 @@ func (s *InfluxSink) Write(m lp.CCMetric) error {
|
|||||||
// Check that encoding worked
|
// Check that encoding worked
|
||||||
if err := s.encoder.Err(); err != nil {
|
if err := s.encoder.Err(); err != nil {
|
||||||
cclog.ComponentError(s.name, "Write():", "Encoding failed:", err)
|
cclog.ComponentError(s.name, "Write():", "Encoding failed:", err)
|
||||||
|
|
||||||
|
// Unlock access to batch slice
|
||||||
|
s.batchMutex.Unlock()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,9 +283,13 @@ func (s *InfluxSink) Write(m lp.CCMetric) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Unlock access to batch slice
|
||||||
|
s.batchMutex.Unlock()
|
||||||
return s.Flush()
|
return s.Flush()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Unlock access to batch slice
|
||||||
|
s.batchMutex.Unlock()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user