docker stats: fix 'panic: close of closed channel'
Signed-off-by: fanjiyun <fan.jiyun@zte.com.cn>
This commit is contained in:
parent
7cf6dfcb9e
commit
1b8826beee
|
@ -66,8 +66,11 @@ func (p *Publisher) SubscribeTopicWithBuffer(topic topicFunc, buffer int) chan i
|
||||||
// Evict removes the specified subscriber from receiving any more messages.
|
// Evict removes the specified subscriber from receiving any more messages.
|
||||||
func (p *Publisher) Evict(sub chan interface{}) {
|
func (p *Publisher) Evict(sub chan interface{}) {
|
||||||
p.m.Lock()
|
p.m.Lock()
|
||||||
|
_, exists := p.subscribers[sub]
|
||||||
|
if exists {
|
||||||
delete(p.subscribers, sub)
|
delete(p.subscribers, sub)
|
||||||
close(sub)
|
close(sub)
|
||||||
|
}
|
||||||
p.m.Unlock()
|
p.m.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue