Skip to content

Commit

Permalink
Merge pull request #41584 from fanjiyun/fix-docker-stats-panic
Browse files Browse the repository at this point in the history
docker stats: fix 'panic: close of closed channel'
  • Loading branch information
AkihiroSuda authored Oct 26, 2020
2 parents a9e867f + 3aa019e commit a512c76
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ func (p *Publisher) SubscribeTopicWithBuffer(topic topicFunc, buffer int) chan i
// Evict removes the specified subscriber from receiving any more messages.
func (p *Publisher) Evict(sub chan interface{}) {
p.m.Lock()
delete(p.subscribers, sub)
close(sub)
_, exists := p.subscribers[sub]
if exists {
delete(p.subscribers, sub)
close(sub)
}
p.m.Unlock()
}

Expand Down

0 comments on commit a512c76

Please sign in to comment.