plugin/metrcs: fix datarace on listeners (#2835)

This fixes a data race on the listener(s) that get started in the
metrics plugins.

It also restore pkg/uniq to its former glory and removes and state being
carried in there; this means for metrics that registry.go was to
replicate that behavior *with* locking (as pkg/uniq doesn't do, or need
that).

Also renamed uniqAddr to just u, to make it slightly shorter.

Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
Miek Gieben 2019-05-18 18:34:46 +01:00 committed by GitHub
parent d41e9ff7b7
commit 118b0c9408
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 62 additions and 30 deletions

View file

@ -4,7 +4,7 @@ import "testing"
func TestForEach(t *testing.T) {
u, i := New(), 0
u.Set("test", func() error { i++; return nil }, nil)
u.Set("test", func() error { i++; return nil })
u.ForEach()
if i != 1 {