зеркало из https://github.com/docker/go-events.git
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 <lk4d4math@gmail.com>
This commit is contained in:
Родитель
18b43f1bc8
Коммит
834ad85c70
|
@ -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.
|
||||
|
||||
|
|
|
@ -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{}{
|
||||
|
|
2
retry.go
2
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{}{
|
||||
|
|
Загрузка…
Ссылка в новой задаче