add read lock in load/import/pull to fix GC preempts to exit subprocess

Signed-off-by: jingxiaolu <lujingxiao@huawei.com>
This commit is contained in:
jingxiaolu 2022-12-07 09:43:56 +08:00
parent 2dd999867f
commit 14dc79a977
5 changed files with 67 additions and 3 deletions

View File

@ -1 +1 @@
0.9.6-14
0.9.6-15

View File

@ -1 +1 @@
e4b5a3bee5a69df32fb60b5eb8c28e1e8a39b59b
a5b09eac902299ff56b460324b6cb4db18a16a25

View File

@ -2,7 +2,7 @@
Name: isula-build
Version: 0.9.6
Release: 14
Release: 15
Summary: A tool to build container images
License: Mulan PSL V2
URL: https://gitee.com/openeuler/isula-build
@ -85,6 +85,12 @@ fi
/usr/share/bash-completion/completions/isula-build
%changelog
* Wed Dec 07 2022 jingxiaolu <lujingxiao@huawei.com> - 0.9.6-15
- Type:bugfix
- CVE:NA
- SUG:restart
- DESC:add read lock in load/import/pull to fix GC preempts to exit subprocess
* Wed Nov 23 2022 Lixiang <cooper.li@huawei.com> - 0.9.6-14
- Type:bugfix
- CVE:NA

View File

@ -0,0 +1,57 @@
From f8952b39aa9251b7a46fcaf894a1afd9c0a2d5de Mon Sep 17 00:00:00 2001
From: daisicheng <daisicheng@huawei.com>
Date: Tue, 6 Dec 2022 10:41:34 +0800
Subject: [PATCH] add read lock in load, import and pull to fix the problem
that GC preempts to exit subprocess
---
daemon/import.go | 3 +++
daemon/load.go | 3 +++
daemon/pull.go | 3 +++
3 files changed, 9 insertions(+)
diff --git a/daemon/import.go b/daemon/import.go
index 21ab729..a0a475d 100644
--- a/daemon/import.go
+++ b/daemon/import.go
@@ -38,6 +38,9 @@ import (
// Import an image from a tarball
func (b *Backend) Import(req *pb.ImportRequest, stream pb.Control_ImportServer) error {
+ b.daemon.RLock()
+ defer b.daemon.RUnlock()
+
var (
srcRef types.ImageReference
ctx = stream.Context()
diff --git a/daemon/load.go b/daemon/load.go
index 2d0c154..c071374 100644
--- a/daemon/load.go
+++ b/daemon/load.go
@@ -79,6 +79,9 @@ func (b *Backend) getLoadOptions(req *pb.LoadRequest) (LoadOptions, error) {
// Load loads the image
func (b *Backend) Load(req *pb.LoadRequest, stream pb.Control_LoadServer) error {
+ b.daemon.RLock()
+ defer b.daemon.RUnlock()
+
logrus.WithFields(logrus.Fields{
"LoadID": req.GetLoadID(),
}).Info("LoadRequest received")
diff --git a/daemon/pull.go b/daemon/pull.go
index 90be2a9..dc8af03 100644
--- a/daemon/pull.go
+++ b/daemon/pull.go
@@ -40,6 +40,9 @@ type pullOptions struct {
// Pull receives a pull request and pull the image from remote repository
func (b *Backend) Pull(req *pb.PullRequest, stream pb.Control_PullServer) error {
+ b.daemon.RLock()
+ defer b.daemon.RUnlock()
+
logrus.WithFields(logrus.Fields{
"PullID": req.GetPullID(),
"ImageName": req.GetImageName(),
--
2.34.1

View File

@ -36,3 +36,4 @@ patch/0124-add-the-constraints-and-limitations-of-the-doc.patch
patch/0125-fix-the-possible-file-leakage-problem-in-util-cipher.patch
patch/0126-improve-security-compile-option-of-isula-build-binar.patch
patch/0127-Fix-the-problem-that-the-var-lib-isula-build-storage.patch
patch/0128-add-read-lock-in-load-import-and-pull-to-fix-the-pro.patch