dpu-utilities/0004-fix-rexec-exit-code-bug-and-fix-some-warning.patch

116 lines
3.8 KiB
Diff
Raw Normal View History

From f624bc7602c459de3cbbcd691309c1c66438d109 Mon Sep 17 00:00:00 2001
From: liqiang <liqiang64@huawei.com>
Date: Mon, 11 Dec 2023 10:46:07 +0800
Subject: [PATCH 04/12] fix rexec exit code bug, and fix some warning
Signed-off-by: liqiang <liqiang64@huawei.com>
---
qtfs/qtfs/qtfs-mod.c | 6 +++---
qtfs/rexec/rexec.c | 11 ++++++-----
qtfs/rexec/rexec_server.c | 6 ++++--
3 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/qtfs/qtfs/qtfs-mod.c b/qtfs/qtfs/qtfs-mod.c
index c4ef72c..0b6cd65 100644
--- a/qtfs/qtfs/qtfs-mod.c
+++ b/qtfs/qtfs/qtfs-mod.c
@@ -66,7 +66,7 @@ void *qtfs_remote_run(struct qtfs_conn_var_s *pvar, unsigned int type, unsigned
if (ret <= 0) {
qtfs_err("qtfs remote run send failed, ret:%d pvar sendlen:%lu.", ret, pvar->vec_send.iov_len);
qtinfo_senderrinc(req->type);
- return (void *)ret;
+ return ERR_PTR(ret);
}
qtinfo_sendinc(type);
@@ -100,7 +100,7 @@ retry:
}
if (retrytimes >= 5 && ret == -EINTR) {
qtfs_err("qtfs conn recv get retry signal(%d) too many times, stop retrying, signal:0x%lx", ret, (unsigned long)current->pending.signal.sig[0]);
- return (void *)ret;
+ return ERR_PTR(ret);
}
retrytimes++;
msleep(1);
@@ -109,7 +109,7 @@ retry:
if (ret < 0) {
qtfs_err("qtfs remote run error, req_type:%u, ret:%d.", req->type, ret);
qtinfo_recverrinc(req->type);
- return (void *)ret;
+ return ERR_PTR(ret);
}
if (retrytimes > 0)
qtfs_debug("qtfs remote run retry times:%lu.", retrytimes);
diff --git a/qtfs/rexec/rexec.c b/qtfs/rexec/rexec.c
index 060abc5..e24c0ad 100644
--- a/qtfs/rexec/rexec.c
+++ b/qtfs/rexec/rexec.c
@@ -183,7 +183,7 @@ static int rexec_conn_msg(struct rexec_client_event *evt)
}
} else {
char msg[sizeof(struct rexec_msg) + 1];
- struct rexec_msg *hs = msg;
+ struct rexec_msg *hs = (struct rexec_msg *)msg;
char *ok = hs->msg;
hs->msgtype = REXEC_HANDSHAKE;
hs->msglen = 1;
@@ -558,7 +558,7 @@ err_end:
static int rexec_handshake_proc(struct rexec_client_event *evt)
{
char msg[sizeof(struct rexec_msg) + 1];
- struct rexec_msg *hs = msg;
+ struct rexec_msg *hs = (struct rexec_msg *)msg;
int ret = read(evt->fd, hs->msg, 1);
if (ret <= 0) {
rexec_err("read from handshake pipe failed, ret:%d err:%d", ret, errno);
@@ -686,8 +686,9 @@ static void *rexec_pipe_proxy_thread(void *arg)
static void *rexec_conn_thread(void *arg)
{
struct rexec_thread_arg *parg = (struct rexec_thread_arg *)arg;
+ int exit_status = rexec_run(parg->efd, parg->connfd, parg->argv);
- return (void *)rexec_run(parg->efd, parg->connfd, parg->argv);
+ pthread_exit((void *)&exit_status);
}
static void rexec_global_var_init()
@@ -763,9 +764,9 @@ int main(int argc, char *argv[])
connarg.connfd = connfd;
connarg.argv = argv;
(void)pthread_create(&thrd_conn, NULL, rexec_conn_thread, &connarg);
- pthread_join(thrd_conn, (void *)&exit_status);
+ pthread_join(thrd_conn, (void **)&exit_status);
fclose(rexec_logfile);
- exit((int)exit_status);
+ exit(*(int *)exit_status);
err_end:
fclose(rexec_logfile);
rexec_logfile = NULL;
diff --git a/qtfs/rexec/rexec_server.c b/qtfs/rexec/rexec_server.c
index 7182a9e..5e571fd 100644
--- a/qtfs/rexec/rexec_server.c
+++ b/qtfs/rexec/rexec_server.c
@@ -379,7 +379,7 @@ static int rexec_start_new_process(int newconnfd)
char *ack;
int mypid = getpid();
char msg[sizeof(struct rexec_msg) + 1];
- struct rexec_msg *pm = msg;
+ struct rexec_msg *pm = (struct rexec_msg *)msg;
pm->msgtype = REXEC_PIDMAP;
pm->msglen = 0;
pm->pid = mypid;
@@ -443,7 +443,9 @@ err_free:
err_to_parent:
do {
int errpid = -1;
- write(pipefd[PIPE_WRITE], &errpid, sizeof(int));
+ if (write(pipefd[PIPE_WRITE], &errpid, sizeof(int)) <= 0) {
+ rexec_err("write err ack to parent failed, errno:%d", errno);
+ }
} while (0);
exit(0);
--
2.37.1 (Apple Git-137.1)