From d247425e030276279282392f212b48a09e47622c Mon Sep 17 00:00:00 2001 From: Daniel Nelson Date: Mon, 2 Apr 2018 12:52:23 -0700 Subject: [PATCH] Add mutex to influx parser --- plugins/parsers/influx/parser.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/parsers/influx/parser.go b/plugins/parsers/influx/parser.go index 98f9cf65f..53acd5eff 100644 --- a/plugins/parsers/influx/parser.go +++ b/plugins/parsers/influx/parser.go @@ -3,6 +3,7 @@ package influx import ( "errors" "fmt" + "sync" "github.com/influxdata/telegraf" ) @@ -32,6 +33,7 @@ func (e *ParseError) Error() string { type Parser struct { DefaultTags map[string]string + sync.Mutex *machine handler *MetricHandler } @@ -44,6 +46,8 @@ func NewParser(handler *MetricHandler) *Parser { } func (p *Parser) Parse(input []byte) ([]telegraf.Metric, error) { + p.Lock() + defer p.Unlock() metrics := make([]telegraf.Metric, 0) p.machine.SetData(input)