iSulad/0046-free-timeout-when-shim_create-finished.patch
zhangxiaoyu 5ec852595b bugfix for runc and cri
Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
(cherry picked from commit 9c3acba9915c23718ae8a806daa49022a73756eb)
2023-04-25 14:57:24 +08:00

90 lines
3.3 KiB
Diff

From 4dfc94f2beb816eb2e26ede07e803a230405b193 Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Thu, 20 Apr 2023 13:28:26 +0800
Subject: [PATCH 46/46] free timeout when shim_create finished
Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
.../modules/runtime/isula/isula_rt_ops.c | 30 +++++++++++++------
1 file changed, 21 insertions(+), 9 deletions(-)
diff --git a/src/daemon/modules/runtime/isula/isula_rt_ops.c b/src/daemon/modules/runtime/isula/isula_rt_ops.c
index 3a6269a1..ceaf464e 100644
--- a/src/daemon/modules/runtime/isula/isula_rt_ops.c
+++ b/src/daemon/modules/runtime/isula/isula_rt_ops.c
@@ -694,7 +694,7 @@ static int status_to_exit_code(int status)
}
static int shim_create(bool fg, const char *id, const char *workdir, const char *bundle, const char *runtime_cmd,
- int *exit_code, const int64_t timeout)
+ int *exit_code, const char* timeout)
{
pid_t pid = 0;
int exec_fd[2] = { -1, -1 };
@@ -712,12 +712,8 @@ static int shim_create(bool fg, const char *id, const char *workdir, const char
params[i++] = runtime_cmd;
params[i++] = "info";
// execSync timeout
- if (timeout > 0) {
- params[i] = util_int_to_string(timeout);
- if (params[i] == NULL) {
- ERROR("Failed to convert execSync timeout %ld to string", timeout);
- return -1;
- }
+ if (timeout != NULL) {
+ params[i++] = timeout;
}
runtime_exec_param_dump(params);
@@ -917,7 +913,7 @@ int rt_isula_create(const char *id, const char *runtime, const rt_create_params_
}
get_runtime_cmd(runtime, &cmd);
- ret = shim_create(false, id, workdir, params->bundle, cmd, NULL, -1);
+ ret = shim_create(false, id, workdir, params->bundle, cmd, NULL, NULL);
if (ret != 0) {
runtime_call_delete_force(workdir, runtime, id);
ERROR("%s: failed create shim process", id);
@@ -1099,6 +1095,7 @@ int rt_isula_exec(const char *id, const char *runtime, const rt_exec_params_t *p
char bundle[PATH_MAX] = { 0 };
int pid = 0;
shim_client_process_state p = { 0 };
+ char *timeout = NULL;
if (id == NULL || runtime == NULL || params == NULL || exit_code == NULL || params->suffix == NULL) {
ERROR("nullptr arguments not allowed");
@@ -1158,7 +1155,18 @@ int rt_isula_exec(const char *id, const char *runtime, const rt_exec_params_t *p
}
get_runtime_cmd(runtime, &cmd);
- ret = shim_create(fg_exec(params), id, workdir, bundle, cmd, exit_code, params->timeout);
+
+ // execSync timeout
+ if (params->timeout > 0) {
+ timeout = util_int_to_string(params->timeout);
+ if (timeout == NULL) {
+ ERROR("Failed to convert execSync timeout %ld to string", params->timeout);
+ ret = -1;
+ goto del_out;
+ }
+ }
+
+ ret = shim_create(fg_exec(params), id, workdir, bundle, cmd, exit_code, timeout);
if (ret != 0) {
ERROR("%s: failed create shim process for exec %s", id, exec_id);
goto errlog_out;
@@ -1183,6 +1191,10 @@ errlog_out:
show_shim_runtime_errlog(workdir);
}
+ if (timeout != NULL) {
+ free(timeout);
+ }
+
del_out:
if (util_recursive_rmdir(workdir, 0)) {
ERROR("rmdir %s failed", workdir);
--
2.25.1