Merge pull request #41584 from fanjiyun/fix-docker-stats-panic

docker stats: fix 'panic: close of closed channel'
This commit is contained in:
Akihiro Suda 2020-10-26 20:35:51 +09:00 committed by GitHub
commit 837ee91cb9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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()
}