1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

docker stats: fix 'panic: close of closed channel'

Signed-off-by: fanjiyun <fan.jiyun@zte.com.cn>
This commit is contained in:
fanjiyun 2020-10-24 11:47:53 +08:00
parent 7cf6dfcb9e
commit 1b8826beee

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