0069-containerd-add-check-in-spec.patch 0070-containerd-kill-container-init-process-if-runc-start.patch 0071-containerd-fix-containerd-shim-residual-when-kill-co.patch 0072-containerd-fix-deadlock-on-commit-error.patch 0073-containerd-backport-upstream-patches.patch 0074-containerd-fix-exec-event-missing-due-to-pid-reuse.patch 0075-containerd-fix-dm-left-when-pause-contaienr-and-kill-shim.patch 0076-containerd-fix-start-container-failed-with-id-exists.patch 0077-containerd-drop-opt-package.patch 0078-containerd-bump-containerd-ttrpc-699c4e40d1.patch 0079-containerd-fix-race-access-for-mobySubcribed.patch 0080-containerd-improve-log-for-debugging.patch 0081-containerd-reduce-permissions-for-bundle-di.patch 0082-containerd-fix-publish-command-wait-block-for.patch 0083-containerd-optimize-cgo-compile-options.patch Signed-off-by:songyanting <songyanting@huawei.com>
48 lines
1.4 KiB
Diff
48 lines
1.4 KiB
Diff
From fe8f7f5acac4f0fcf75218e26c1f3f874a77bf44 Mon Sep 17 00:00:00 2001
|
|
From: xiadanni <xiadanni1@huawei.com>
|
|
Date: Wed, 1 Sep 2021 07:29:43 +0800
|
|
Subject: [PATCH] [Huawei]containerd:fix race access for mobySubcribed
|
|
|
|
Signed-off-by: xiadanni <xiadanni1@huawei.com>
|
|
---
|
|
events/exchange/exchange.go | 7 ++++---
|
|
1 file changed, 4 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/events/exchange/exchange.go b/events/exchange/exchange.go
|
|
index 540f18054..ad642563a 100644
|
|
--- a/events/exchange/exchange.go
|
|
+++ b/events/exchange/exchange.go
|
|
@@ -19,6 +19,7 @@ package exchange
|
|
import (
|
|
"context"
|
|
"strings"
|
|
+ "sync/atomic"
|
|
"time"
|
|
|
|
"github.com/containerd/containerd/errdefs"
|
|
@@ -49,10 +50,10 @@ func NewExchange() *Exchange {
|
|
var _ events.Publisher = &Exchange{}
|
|
var _ events.Forwarder = &Exchange{}
|
|
var _ events.Subscriber = &Exchange{}
|
|
-var mobySubcribed = false
|
|
+var mobySubcribed = int32(0)
|
|
|
|
func MobySubscribed() bool {
|
|
- return mobySubcribed
|
|
+ return atomic.LoadInt32(&mobySubcribed) == 1
|
|
}
|
|
|
|
// Forward accepts an envelope to be direcly distributed on the exchange.
|
|
@@ -170,7 +171,7 @@ func (e *Exchange) Subscribe(ctx context.Context, fs ...string) (ch <-chan *even
|
|
for _, s := range fs {
|
|
if !MobySubscribed() && s == "namespace==moby,topic~=|^/tasks/|" {
|
|
queue.Namespace = "moby"
|
|
- mobySubcribed = true
|
|
+ atomic.StoreInt32(&mobySubcribed, 1)
|
|
}
|
|
}
|
|
|
|
--
|
|
2.27.0
|
|
|