From 834ad85c709fc268fe7175207d548a34196bba30 Mon Sep 17 00:00:00 2001 From: Alexander Morozov Date: Mon, 29 Aug 2016 10:22:11 -0700 Subject: [PATCH] all: fix sync.Once copy We're doing object copy on String call, but it makes race detector angry: copy of sync.Once and changing its state at the same time. Also, it fixes three vet warnings about passing lock by value. Signed-off-by: Alexander Morozov --- broadcast.go | 2 +- channel.go | 2 +- retry.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/broadcast.go b/broadcast.go index ee0a894..567c1a1 100644 --- a/broadcast.go +++ b/broadcast.go @@ -160,7 +160,7 @@ func (b *Broadcaster) run() { } } -func (b Broadcaster) String() string { +func (b *Broadcaster) String() string { // Serialize copy of this broadcaster without the sync.Once, to avoid // a data race. diff --git a/channel.go b/channel.go index de95fa4..802cf51 100644 --- a/channel.go +++ b/channel.go @@ -50,7 +50,7 @@ func (ch *Channel) Close() error { return nil } -func (ch Channel) String() string { +func (ch *Channel) String() string { // Serialize a copy of the Channel that doesn't contain the sync.Once, // to avoid a data race. ch2 := map[string]interface{}{ diff --git a/retry.go b/retry.go index 55d40dc..8f6c37c 100644 --- a/retry.go +++ b/retry.go @@ -90,7 +90,7 @@ func (rs *RetryingSink) Close() error { return nil } -func (rs RetryingSink) String() string { +func (rs *RetryingSink) String() string { // Serialize a copy of the RetryingSink without the sync.Once, to avoid // a data race. rs2 := map[string]interface{}{