!454 sync from openEuler
From: @duguhaotian Reviewed-by: @jingwoo Signed-off-by: @jingwoo
This commit is contained in:
commit
9596af5ab9
@ -1,7 +1,7 @@
|
||||
From 199971d61cc53ee11b16b353bcd0594abc86cb3e Mon Sep 17 00:00:00 2001
|
||||
From: WangFengTu <wangfengtu@huawei.com>
|
||||
Date: Fri, 26 Aug 2022 09:33:05 +0800
|
||||
Subject: [PATCH 1/5] fix memleak
|
||||
Subject: [PATCH 01/11] fix memleak
|
||||
|
||||
Signed-off-by: WangFengTu <wangfengtu@huawei.com>
|
||||
---
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
From bf50cef67ac2288bed7013c675df8d35f370dc32 Mon Sep 17 00:00:00 2001
|
||||
From: zhangxiaoyu <zhangxiaoyu58@huawei.com>
|
||||
Date: Sat, 27 Aug 2022 10:40:02 +0800
|
||||
Subject: [PATCH 2/5] cleancode about rest register container
|
||||
Subject: [PATCH 02/11] cleancode about rest register container
|
||||
|
||||
Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
|
||||
---
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
From 194eb950ea072ac313635d75dc3913f48e300edf Mon Sep 17 00:00:00 2001
|
||||
From: wujing <wujing50@huawei.com>
|
||||
Date: Wed, 11 May 2022 18:25:40 +0800
|
||||
Subject: [PATCH 3/5] adapt to openssl 3.0
|
||||
Subject: [PATCH 03/11] adapt to openssl 3.0
|
||||
|
||||
SHA512_Init&SHA512_Update&SHA512_Final function have been deprecated since OpenSSL 3.0
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
From 64ef4f52a1f75be2dbd1b750a52500818790f501 Mon Sep 17 00:00:00 2001
|
||||
From: wujing <wujing50@huawei.com>
|
||||
Date: Thu, 1 Sep 2022 09:41:50 +0800
|
||||
Subject: [PATCH 4/5] remove redundant header files
|
||||
Subject: [PATCH 04/11] remove redundant header files
|
||||
|
||||
Signed-off-by: wujing <wujing50@huawei.com>
|
||||
---
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
From 5a0476a328a39764874257faa23696320656d3e3 Mon Sep 17 00:00:00 2001
|
||||
From: zhangxiaoyu <zhangxiaoyu58@huawei.com>
|
||||
Date: Tue, 6 Sep 2022 18:45:53 +0800
|
||||
Subject: [PATCH 5/5] add isulad args
|
||||
Subject: [PATCH 05/11] add isulad args
|
||||
|
||||
Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
|
||||
---
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
From 710aa3de0e21c3566934897dd34a9ac497f808a7 Mon Sep 17 00:00:00 2001
|
||||
From: zhangxiaoyu <zhangxiaoyu58@huawei.com>
|
||||
Date: Thu, 8 Sep 2022 10:14:39 +0800
|
||||
Subject: [PATCH 6/6] invalid free default-runtime and cri-runtime after free
|
||||
Subject: [PATCH 06/11] invalid free default-runtime and cri-runtime after free
|
||||
json-confs
|
||||
|
||||
Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
From 15314b8d4159da27717e3e835e2cb0f90b3f7e02 Mon Sep 17 00:00:00 2001
|
||||
From: zhangxiaoyu <zhangxiaoyu58@huawei.com>
|
||||
Date: Tue, 13 Sep 2022 20:20:58 +1400
|
||||
Subject: [PATCH] calculate timezone by tm_gmtoff
|
||||
Date: Tue, 13 Sep 2022 20:21:25 +1400
|
||||
Subject: [PATCH 07/11] calculate timezone by tm_gmtoff
|
||||
|
||||
Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
|
||||
---
|
||||
|
||||
135
0008-fixbug-add-hostname-env-for-container.patch
Normal file
135
0008-fixbug-add-hostname-env-for-container.patch
Normal file
@ -0,0 +1,135 @@
|
||||
From 502cf70a63afa5b5a728d7813b1ff1481badf63a Mon Sep 17 00:00:00 2001
|
||||
From: haozi007 <liuhao27@huawei.com>
|
||||
Date: Thu, 8 Sep 2022 20:29:36 +0800
|
||||
Subject: [PATCH 08/11] [fixbug] add hostname env for container
|
||||
|
||||
Signed-off-by: haozi007 <liuhao27@huawei.com>
|
||||
---
|
||||
.../executor/container_cb/execution_network.c | 16 +++++++------
|
||||
src/daemon/modules/spec/specs.c | 13 +++++-----
|
||||
src/daemon/modules/spec/specs_extend.c | 24 ++++++++++++++-----
|
||||
3 files changed, 34 insertions(+), 19 deletions(-)
|
||||
|
||||
diff --git a/src/daemon/executor/container_cb/execution_network.c b/src/daemon/executor/container_cb/execution_network.c
|
||||
index fa0ec612..bbc35e80 100644
|
||||
--- a/src/daemon/executor/container_cb/execution_network.c
|
||||
+++ b/src/daemon/executor/container_cb/execution_network.c
|
||||
@@ -890,17 +890,19 @@ static int create_default_hostname(const char *id, const char *rootpath, bool sh
|
||||
char hostname_content[MAX_HOST_NAME_LEN + 2] = { 0 };
|
||||
|
||||
if (v2_spec->config->hostname == NULL) {
|
||||
+ char hostname[MAX_HOST_NAME_LEN] = { 0 };
|
||||
if (share_host) {
|
||||
- char hostname[MAX_HOST_NAME_LEN] = { 0x00 };
|
||||
ret = gethostname(hostname, sizeof(hostname));
|
||||
- if (ret != 0) {
|
||||
- ERROR("Get hostname error");
|
||||
- goto out;
|
||||
- }
|
||||
- v2_spec->config->hostname = util_strdup_s(hostname);
|
||||
} else {
|
||||
- v2_spec->config->hostname = util_strdup_s("localhost");
|
||||
+ // max length of hostname from ID is 12 + '\0'
|
||||
+ nret = snprintf(hostname, 13, "%s", id);
|
||||
+ ret = nret < 0 ? 1 : 0;
|
||||
+ }
|
||||
+ if (ret != 0) {
|
||||
+ ERROR("Create hostname error");
|
||||
+ goto out;
|
||||
}
|
||||
+ v2_spec->config->hostname = util_strdup_s(hostname);
|
||||
}
|
||||
|
||||
nret = snprintf(file_path, PATH_MAX, "%s/%s/%s", rootpath, id, "hostname");
|
||||
diff --git a/src/daemon/modules/spec/specs.c b/src/daemon/modules/spec/specs.c
|
||||
index 44e38674..ec6385a6 100644
|
||||
--- a/src/daemon/modules/spec/specs.c
|
||||
+++ b/src/daemon/modules/spec/specs.c
|
||||
@@ -2112,6 +2112,13 @@ int merge_all_specs(host_config *host_spec, const char *real_rootfs, container_c
|
||||
goto out;
|
||||
}
|
||||
|
||||
+ // should before merge process env
|
||||
+ ret = merge_hostname(oci_spec, host_spec, v2_spec->config);
|
||||
+ if (ret != 0) {
|
||||
+ ERROR("Failed to merge hostname");
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
ret = merge_process_conf(oci_spec, host_spec, v2_spec->config);
|
||||
if (ret != 0) {
|
||||
goto out;
|
||||
@@ -2138,12 +2145,6 @@ int merge_all_specs(host_config *host_spec, const char *real_rootfs, container_c
|
||||
goto out;
|
||||
}
|
||||
|
||||
- ret = merge_hostname(oci_spec, host_spec, v2_spec->config);
|
||||
- if (ret != 0) {
|
||||
- ERROR("Failed to merge hostname");
|
||||
- goto out;
|
||||
- }
|
||||
-
|
||||
ret = make_annotations(oci_spec, v2_spec->config, host_spec);
|
||||
if (ret != 0) {
|
||||
ret = -1;
|
||||
diff --git a/src/daemon/modules/spec/specs_extend.c b/src/daemon/modules/spec/specs_extend.c
|
||||
index 6276a586..c8faa102 100644
|
||||
--- a/src/daemon/modules/spec/specs_extend.c
|
||||
+++ b/src/daemon/modules/spec/specs_extend.c
|
||||
@@ -415,13 +415,19 @@ out:
|
||||
int merge_env(oci_runtime_spec *oci_spec, const char **env, size_t env_len)
|
||||
{
|
||||
int ret = 0;
|
||||
+ int nret = 0;
|
||||
size_t new_size = 0;
|
||||
size_t old_size = 0;
|
||||
- size_t i = 0;
|
||||
+ size_t i;
|
||||
char **temp = NULL;
|
||||
+ // 10 is lenght of "HOSTNAME=" and '\0'
|
||||
+ char host_name_env[MAX_HOST_NAME_LEN + 10] = { 0 };
|
||||
|
||||
- if (env_len == 0 || env == NULL) {
|
||||
- return 0;
|
||||
+ nret = snprintf(host_name_env, sizeof(host_name_env), "HOSTNAME=%s", oci_spec->hostname);
|
||||
+ if (nret < 0 || (size_t)nret >= sizeof(host_name_env)) {
|
||||
+ ret = -1;
|
||||
+ ERROR("Sprint failed");
|
||||
+ goto out;
|
||||
}
|
||||
|
||||
ret = make_sure_oci_spec_process(oci_spec);
|
||||
@@ -429,13 +435,14 @@ int merge_env(oci_runtime_spec *oci_spec, const char **env, size_t env_len)
|
||||
goto out;
|
||||
}
|
||||
|
||||
- if (env_len > LIST_ENV_SIZE_MAX - oci_spec->process->env_len) {
|
||||
+ if (env_len > LIST_ENV_SIZE_MAX - oci_spec->process->env_len - 1) {
|
||||
ERROR("The length of envionment variables is too long, the limit is %lld", LIST_ENV_SIZE_MAX);
|
||||
isulad_set_error_message("The length of envionment variables is too long, the limit is %d", LIST_ENV_SIZE_MAX);
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
- new_size = (oci_spec->process->env_len + env_len) * sizeof(char *);
|
||||
+ // add 1 for hostname env
|
||||
+ new_size = (oci_spec->process->env_len + env_len + 1) * sizeof(char *);
|
||||
old_size = oci_spec->process->env_len * sizeof(char *);
|
||||
ret = util_mem_realloc((void **)&temp, new_size, oci_spec->process->env, old_size);
|
||||
if (ret != 0) {
|
||||
@@ -445,7 +452,12 @@ int merge_env(oci_runtime_spec *oci_spec, const char **env, size_t env_len)
|
||||
}
|
||||
|
||||
oci_spec->process->env = temp;
|
||||
- for (i = 0; i < env_len; i++) {
|
||||
+
|
||||
+ // append hostname env into default oci spec env list
|
||||
+ oci_spec->process->env[oci_spec->process->env_len] = util_strdup_s(host_name_env);
|
||||
+ oci_spec->process->env_len++;
|
||||
+
|
||||
+ for (i = 0; i < env_len && env != NULL; i++) {
|
||||
oci_spec->process->env[oci_spec->process->env_len] = util_strdup_s(env[i]);
|
||||
oci_spec->process->env_len++;
|
||||
}
|
||||
--
|
||||
2.25.1
|
||||
|
||||
35
0009-add-testcase-for-check-env-HOSTNAME.patch
Normal file
35
0009-add-testcase-for-check-env-HOSTNAME.patch
Normal file
@ -0,0 +1,35 @@
|
||||
From b0664f10a349563376a0db00c1524d01599cd697 Mon Sep 17 00:00:00 2001
|
||||
From: haozi007 <liuhao27@huawei.com>
|
||||
Date: Wed, 14 Sep 2022 10:49:22 +0800
|
||||
Subject: [PATCH 09/11] add testcase for check env HOSTNAME
|
||||
|
||||
Signed-off-by: haozi007 <liuhao27@huawei.com>
|
||||
---
|
||||
CI/test_cases/container_cases/run.sh | 11 +++++++++++
|
||||
1 file changed, 11 insertions(+)
|
||||
|
||||
diff --git a/CI/test_cases/container_cases/run.sh b/CI/test_cases/container_cases/run.sh
|
||||
index 29c761d3..1dea51ab 100755
|
||||
--- a/CI/test_cases/container_cases/run.sh
|
||||
+++ b/CI/test_cases/container_cases/run.sh
|
||||
@@ -26,6 +26,17 @@ source ../helpers.sh
|
||||
function do_test_t()
|
||||
{
|
||||
containername=test_basic_run
|
||||
+
|
||||
+ tid=$(isula run --name $containername -td busybox)
|
||||
+ hostname=$(isula exec -it $containername hostname)
|
||||
+ fn_check_eq "${hostname}" "${tid:0:12}" "default hostname is not id of container"
|
||||
+ isula exec -it $containername env | grep HOSTNAME
|
||||
+ fn_check_eq "$?" "0" "check HOSTNAME env failed"
|
||||
+ isula stop -t 0 $tid
|
||||
+ fn_check_eq "$?" "0" "stop failed"
|
||||
+ isula rm $tid
|
||||
+ fn_check_eq "$?" "0" "rm failed"
|
||||
+
|
||||
isula run --name $containername -td busybox
|
||||
fn_check_eq "$?" "0" "run failed"
|
||||
testcontainer $containername running
|
||||
--
|
||||
2.25.1
|
||||
|
||||
105
0010-Add-timezone-CI-test.patch
Normal file
105
0010-Add-timezone-CI-test.patch
Normal file
@ -0,0 +1,105 @@
|
||||
From eaad0bfcd96ffba436413a46bde5bb96db4e754e Mon Sep 17 00:00:00 2001
|
||||
From: zhongtao <taozh97@163.com>
|
||||
Date: Thu, 15 Sep 2022 15:43:42 +1400
|
||||
Subject: [PATCH 10/11] Add timezone CI test
|
||||
|
||||
Signed-off-by: zhongtao <taozh97@163.com>
|
||||
---
|
||||
CI/test_cases/container_cases/timezone.sh | 85 +++++++++++++++++++++++
|
||||
1 file changed, 85 insertions(+)
|
||||
create mode 100644 CI/test_cases/container_cases/timezone.sh
|
||||
|
||||
diff --git a/CI/test_cases/container_cases/timezone.sh b/CI/test_cases/container_cases/timezone.sh
|
||||
new file mode 100644
|
||||
index 00000000..d434477d
|
||||
--- /dev/null
|
||||
+++ b/CI/test_cases/container_cases/timezone.sh
|
||||
@@ -0,0 +1,85 @@
|
||||
+#!/bin/bash
|
||||
+#
|
||||
+# attributes: isulad timezone
|
||||
+# concurrent: NA
|
||||
+# spend time: 10
|
||||
+
|
||||
+#######################################################################
|
||||
+##- Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved.
|
||||
+# - iSulad licensed under the Mulan PSL v2.
|
||||
+# - You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
+# - You may obtain a copy of Mulan PSL v2 at:
|
||||
+# - http://license.coscl.org.cn/MulanPSL2
|
||||
+# - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
+# - IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
+# - PURPOSE.
|
||||
+# - See the Mulan PSL v2 for more details.
|
||||
+##- @Description:CI
|
||||
+##- @Author: zhongtao
|
||||
+##- @Create: 2022-09-13
|
||||
+#######################################################################
|
||||
+
|
||||
+source ../helpers.sh
|
||||
+curcnt_timezone=`readlink /etc/localtime`
|
||||
+
|
||||
+function do_check_timezone()
|
||||
+{
|
||||
+ ln -sf $1 /etc/localtime
|
||||
+ localtime=`date "+%:z" | sed 's/://g'`
|
||||
+
|
||||
+ check_valgrind_log
|
||||
+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - stop isulad failed" && return ${FAILURE}
|
||||
+
|
||||
+ start_isulad_with_valgrind
|
||||
+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - start isulad failed" && return ${FAILURE}
|
||||
+
|
||||
+ containername="test_timezone"
|
||||
+
|
||||
+ isula run --name $containername $2 /bin/sh
|
||||
+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to run container with image: ${image}" && return ${FAILURE}
|
||||
+
|
||||
+ containertime=`isula inspect -f "{{.State.StartedAt}}" $containername | tail -c 7 | sed 's/://g'`
|
||||
+ fn_check_eq "$localtime" "$containertime" "localtime is $localtime get: $containertime"
|
||||
+
|
||||
+ isula rm -f $containername
|
||||
+}
|
||||
+
|
||||
+function test_timezone()
|
||||
+{
|
||||
+ local image="busybox"
|
||||
+ local test="container timezone test => (${FUNCNAME[@]})"
|
||||
+
|
||||
+ msg_info "${test} starting..."
|
||||
+
|
||||
+ isula pull ${image}
|
||||
+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to pull image: ${image}" && return ${FAILURE}
|
||||
+
|
||||
+ isula images | grep busybox
|
||||
+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - missing list image: ${image}" && return ${FAILURE}
|
||||
+
|
||||
+ do_check_timezone "/usr/share/zoneinfo/Pacific/Kiritimati" "$image"
|
||||
+ do_check_timezone "/usr/share/zoneinfo/right/Canada/Newfoundland" "$image"
|
||||
+ do_check_timezone "/usr/share/zoneinfo/Asia/Kolkata" "$image"
|
||||
+ do_check_timezone "/usr/share/zoneinfo/right/Pacific/Chatham" "$image"
|
||||
+ do_check_timezone "/usr/share/zoneinfo/Etc/GMT" "$image"
|
||||
+
|
||||
+ ln -sf $curcnt_timezone /etc/localtime
|
||||
+
|
||||
+ isula rmi ${image}
|
||||
+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to remove image ${image}" && return ${FAILURE}
|
||||
+
|
||||
+ check_valgrind_log
|
||||
+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - stop isulad failed" && return ${FAILURE}
|
||||
+
|
||||
+ start_isulad_with_valgrind
|
||||
+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - start isulad failed" && return ${FAILURE}
|
||||
+
|
||||
+ msg_info "${test} finished with return ${TC_RET_T}..."
|
||||
+ return $TC_RET_T
|
||||
+}
|
||||
+
|
||||
+declare -i ans=0
|
||||
+
|
||||
+test_timezone || ((ans++))
|
||||
+
|
||||
+show_result ${ans} "${curr_path}/${0}"
|
||||
--
|
||||
2.25.1
|
||||
|
||||
167
0011-fix-maybe-uwait-use-after-free.patch
Normal file
167
0011-fix-maybe-uwait-use-after-free.patch
Normal file
@ -0,0 +1,167 @@
|
||||
From 95815fe3332197279259ecc4ace08e2e20a174cf Mon Sep 17 00:00:00 2001
|
||||
From: zhangxiaoyu <zhangxiaoyu58@huawei.com>
|
||||
Date: Wed, 28 Sep 2022 10:57:00 +0800
|
||||
Subject: [PATCH 11/11] fix maybe uwait use after free
|
||||
|
||||
Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
|
||||
---
|
||||
.../graphdriver/devmapper/wrapper_devmapper.c | 77 +++++++++++++++----
|
||||
.../graphdriver/devmapper/wrapper_devmapper.h | 3 +
|
||||
2 files changed, 64 insertions(+), 16 deletions(-)
|
||||
|
||||
diff --git a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/wrapper_devmapper.c b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/wrapper_devmapper.c
|
||||
index 8a1dfff5..2513d64a 100644
|
||||
--- a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/wrapper_devmapper.c
|
||||
+++ b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/wrapper_devmapper.c
|
||||
@@ -359,6 +359,17 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
+void free_udev_wait_pth_t(udev_wait_pth_t* uwait)
|
||||
+{
|
||||
+ if (uwait->cond_init) {
|
||||
+ pthread_cond_destroy(&uwait->wait_cond);
|
||||
+ }
|
||||
+ if (uwait->mutex_init) {
|
||||
+ pthread_mutex_destroy(&uwait->udev_mutex);
|
||||
+ }
|
||||
+ free(uwait);
|
||||
+}
|
||||
+
|
||||
static void *udev_wait_process(void *data)
|
||||
{
|
||||
int ret = 0;
|
||||
@@ -376,13 +387,49 @@ static void *udev_wait_process(void *data)
|
||||
} else {
|
||||
uwait->state = DEV_OK;
|
||||
}
|
||||
+ if (pthread_cond_wait(&uwait->wait_cond, &uwait->udev_mutex) != 0) {
|
||||
+ CRIT("Udev wait condition failed");
|
||||
+ }
|
||||
pthread_mutex_unlock(&uwait->udev_mutex);
|
||||
|
||||
+ free_udev_wait_pth_t(uwait);
|
||||
+
|
||||
out:
|
||||
DAEMON_CLEAR_ERRMSG();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+udev_wait_pth_t *init_udev_wait_pth_t(uint32_t cookie)
|
||||
+{
|
||||
+ udev_wait_pth_t *uwait = NULL;
|
||||
+
|
||||
+ uwait = util_common_calloc_s(sizeof(udev_wait_pth_t));
|
||||
+ if (uwait == NULL) {
|
||||
+ ERROR("Out of memory");
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ uwait->cookie = cookie;
|
||||
+ uwait->state = DEV_INIT;
|
||||
+ uwait->mutex_init = false;
|
||||
+ uwait->cond_init = false;
|
||||
+
|
||||
+ if (pthread_mutex_init(&uwait->udev_mutex, NULL) != 0) {
|
||||
+ ERROR("Udev mutex initialized failed");
|
||||
+ free(uwait);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ uwait->mutex_init = true;
|
||||
+
|
||||
+ if (pthread_cond_init(&uwait->wait_cond, NULL) != 0) {
|
||||
+ ERROR("Udev condition initialized failed");
|
||||
+ free_udev_wait_pth_t(uwait);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ uwait->cond_init = true;
|
||||
+
|
||||
+ return uwait;
|
||||
+}
|
||||
+
|
||||
// UdevWait waits for any processes that are waiting for udev to complete the specified cookie.
|
||||
void dev_udev_wait(uint32_t cookie)
|
||||
{
|
||||
@@ -396,51 +443,49 @@ void dev_udev_wait(uint32_t cookie)
|
||||
return;
|
||||
}
|
||||
|
||||
- uwait = util_common_calloc_s(sizeof(udev_wait_pth_t));
|
||||
+ // free in udev_wait_process
|
||||
+ uwait = init_udev_wait_pth_t(cookie);
|
||||
if (uwait == NULL) {
|
||||
- ERROR("Out of memory");
|
||||
return;
|
||||
}
|
||||
- uwait->cookie = cookie;
|
||||
- uwait->state = DEV_INIT;
|
||||
-
|
||||
- if (pthread_mutex_init(&uwait->udev_mutex, NULL) != 0) {
|
||||
- ERROR("Udev mutex initialized failed");
|
||||
- goto free_out;
|
||||
- }
|
||||
|
||||
if (pthread_create(&tid, NULL, udev_wait_process, uwait) != 0) {
|
||||
ERROR("devmapper: create udev wait process thread error:%s", strerror(errno));
|
||||
- goto free_out;
|
||||
+ free_udev_wait_pth_t(uwait);
|
||||
+ return;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
pthread_mutex_lock(&uwait->udev_mutex);
|
||||
if (uwait->state != DEV_INIT) {
|
||||
pthread_mutex_unlock(&uwait->udev_mutex);
|
||||
- goto free_out;
|
||||
+ goto out;
|
||||
}
|
||||
pthread_mutex_unlock(&uwait->udev_mutex);
|
||||
|
||||
if (gettimeofday(&end, NULL) != 0) {
|
||||
ERROR("devmapper: get time failed");
|
||||
- goto free_out;
|
||||
+ goto out;
|
||||
}
|
||||
|
||||
timeout = (end.tv_sec - start.tv_sec) + (end.tv_usec - start.tv_usec) / 1000000; // seconds
|
||||
if (timeout >= (float)dm_udev_wait_timeout) {
|
||||
if (dm_udev_complete(cookie) != 1) {
|
||||
ERROR("Failed to complete udev cookie %u on udev wait timeout", cookie);
|
||||
- goto free_out;
|
||||
+ goto out;
|
||||
}
|
||||
ERROR("Wait on udev cookie time out");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
-free_out:
|
||||
- pthread_mutex_destroy(&uwait->udev_mutex);
|
||||
- free(uwait);
|
||||
+out:
|
||||
+ pthread_mutex_lock(&uwait->udev_mutex);
|
||||
+ if (pthread_cond_broadcast(&uwait->wait_cond) != 0) {
|
||||
+ ERROR("Failed to broadcast wait conditio");
|
||||
+ }
|
||||
+ pthread_mutex_unlock(&uwait->udev_mutex);
|
||||
+ return;
|
||||
}
|
||||
|
||||
int dev_delete_device_force(const char *name)
|
||||
diff --git a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/wrapper_devmapper.h b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/wrapper_devmapper.h
|
||||
index 6a45db58..5a692980 100644
|
||||
--- a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/wrapper_devmapper.h
|
||||
+++ b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/wrapper_devmapper.h
|
||||
@@ -74,7 +74,10 @@ typedef enum {
|
||||
typedef struct {
|
||||
uint32_t cookie;
|
||||
pthread_mutex_t udev_mutex;
|
||||
+ bool mutex_init;
|
||||
int state; // 0: ok 1:err_udev_wait 2: err_udev_wait_timeout
|
||||
+ pthread_cond_t wait_cond;
|
||||
+ bool cond_init;
|
||||
} udev_wait_pth_t;
|
||||
|
||||
char *dev_strerror(int errnum);
|
||||
--
|
||||
2.25.1
|
||||
|
||||
12
iSulad.spec
12
iSulad.spec
@ -1,5 +1,5 @@
|
||||
%global _version 2.0.16
|
||||
%global _release 7
|
||||
%global _release 8
|
||||
%global is_systemd 1
|
||||
%global enable_shimv2 1
|
||||
%global is_embedded 1
|
||||
@ -20,6 +20,10 @@ Patch0004: 0004-remove-redundant-header-files.patch
|
||||
Patch0005: 0005-add-isulad-args.patch
|
||||
Patch0006: 0006-invalid-free-default-runtime-and-cri-runtime-after-f.patch
|
||||
Patch0007: 0007-calculate-timezone-by-tm_gmtoff.patch
|
||||
Patch0008: 0008-fixbug-add-hostname-env-for-container.patch
|
||||
Patch0009: 0009-add-testcase-for-check-env-HOSTNAME.patch
|
||||
Patch0010: 0010-Add-timezone-CI-test.patch
|
||||
Patch0011: 0011-fix-maybe-uwait-use-after-free.patch
|
||||
|
||||
%ifarch x86_64 aarch64
|
||||
Provides: libhttpclient.so()(64bit)
|
||||
@ -242,6 +246,12 @@ fi
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Thu Sep 29 2022 haozi007 <liuhao27@huawei.com> - 2.0.16-8
|
||||
- Type: enhancement
|
||||
- ID: NA
|
||||
- SUG: NA
|
||||
- DESC: sync from openEuler
|
||||
|
||||
* Tue Sep 20 2022 zhangxiaoyu <zhangxiaoyu58@huawei.com> - 2.0.16-7
|
||||
- Type: enhancement
|
||||
- ID: NA
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user