Fix possible deadlock when output cannot write. (#2610)

This commit is contained in:
Daniel Nelson 2017-03-31 12:45:28 -07:00 committed by GitHub
parent c980c92cd5
commit 540f98e228
2 changed files with 3 additions and 0 deletions

View File

@ -89,6 +89,7 @@ be deprecated eventually.
- [#1827](https://github.com/influxdata/telegraf/issues/1827): Fix Windows Performance Counters multi instance identifier - [#1827](https://github.com/influxdata/telegraf/issues/1827): Fix Windows Performance Counters multi instance identifier
- [#2576](https://github.com/influxdata/telegraf/pull/2576): Add write timeout to Riemann output - [#2576](https://github.com/influxdata/telegraf/pull/2576): Add write timeout to Riemann output
- [#2596](https://github.com/influxdata/telegraf/pull/2596): fix timestamp parsing on prometheus plugin - [#2596](https://github.com/influxdata/telegraf/pull/2596): fix timestamp parsing on prometheus plugin
- [#2610](https://github.com/influxdata/telegraf/pull/2610): Fix deadlock when output cannot write
## v1.2.1 [2017-02-01] ## v1.2.1 [2017-02-01]

View File

@ -45,9 +45,11 @@ func (b *Buffer) Add(metrics ...telegraf.Metric) {
select { select {
case b.buf <- metrics[i]: case b.buf <- metrics[i]:
default: default:
b.mu.Lock()
MetricsDropped.Incr(1) MetricsDropped.Incr(1)
<-b.buf <-b.buf
b.buf <- metrics[i] b.buf <- metrics[i]
b.mu.Unlock()
} }
} }
} }