docker/patch/0237-docker-stats-fix-panic.patch
Song Zhang 725d53a12b docker stats: fix 'panic: close of closed channel'
bugfix: https://gitee.com/src-openeuler/docker/issues/I6LNNW?from=project-issue

Signed-off-by: Song Zhang <zhangsong34@huawei.com>
(cherry picked from commit 8ed0a65d0b666a1f05e3b9c2e0f906859a1c4acb)
2023-03-10 16:39:45 +08:00

31 lines
1.1 KiB
Diff

From 631e56a7e27202529172fe307c7e324a74c56271 Mon Sep 17 00:00:00 2001
From: fanjiyun <fan.jiyun@zte.com.cn>
Date: Sat, 24 Oct 2020 11:47:53 +0800
Subject: [PATCH] docker stats: fix 'panic: close of closed channel'
Signed-off-by: fanjiyun <fan.jiyun@zte.com.cn>
Upstream-commit: 1b8826beee9c86b76091931991f037c1410d0ea5
Component: engine
---
components/engine/pkg/pubsub/publisher.go | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/components/engine/pkg/pubsub/publisher.go b/components/engine/pkg/pubsub/publisher.go
index 32b2f189259..e53d17d515a 100644
--- a/components/engine/pkg/pubsub/publisher.go
+++ b/components/engine/pkg/pubsub/publisher.go
@@ -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()
}