代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/gazelle 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 627773adfafefdf295e680691c3d5b99c6b52c8c Mon Sep 17 00:00:00 2001
From: kircher <majun65@huawei.com>
Date: Tue, 10 Jan 2023 20:35:11 +0800
Subject: [PATCH] add ret check in pthread_create and fix example bug
---
examples/src/utilities.c | 16 +++++++++++++++-
src/lstack/core/lstack_init.c | 10 ++++++----
2 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/examples/src/utilities.c b/examples/src/utilities.c
index b6ed269..38a0d3e 100644
--- a/examples/src/utilities.c
+++ b/examples/src/utilities.c
@@ -124,5 +124,19 @@ int32_t create_socket_and_connect(int32_t *socket_fd, in_addr_t ip, uint16_t por
// set the socket to unblock
int32_t set_socket_unblock(int32_t socket_fd)
{
- return fcntl(socket_fd, F_SETFL, fcntl(socket_fd, F_GETFD, 0) | O_NONBLOCK);
+ int flags = -1;
+
+ flags = fcntl(socket_fd, F_GETFL, 0);
+ if (flags == -1) {
+ printf("get socket flag error, fd:[%d], errno: %d\n", socket_fd, errno);
+ return -1;
+ }
+
+ flags |= O_NONBLOCK;
+ if (fcntl(socket_fd, F_SETFL, flags) == -1) {
+ printf("set socket flag error, fd:[%d], errno: %d\n", socket_fd, errno);
+ return -1;
+ }
+
+ return 0;
}
diff --git a/src/lstack/core/lstack_init.c b/src/lstack/core/lstack_init.c
index 477c5e2..6309d1d 100644
--- a/src/lstack/core/lstack_init.c
+++ b/src/lstack/core/lstack_init.c
@@ -231,16 +231,18 @@ static void create_control_thread(void)
LSTACK_EXIT(1, "control_init_client failed\n");
}
ret = pthread_create(&tid, NULL, (void *(*)(void *))control_client_thread, NULL);
+ if (ret != 0) {
+ LSTACK_EXIT(1, "pthread_create failed ret=%d errno=%d\n", ret, errno);
+ }
} else {
ret = pthread_create(&tid, NULL, (void *(*)(void *))control_server_thread, NULL);
+ if (ret != 0) {
+ LSTACK_EXIT(1, "pthread_create failed ret=%d errno=%d\n", ret, errno);
+ }
ret = dpdk_eal_init();
if (ret < 0) {
LSTACK_EXIT(1, "dpdk_eal_init failed ret=%d errno=%d\n", ret, errno);
}
-
- }
- if (ret != 0) {
- LSTACK_EXIT(1, "pthread_create failed ret=%d errno=%d\n", ret, errno);
}
if (pthread_setname_np(tid, CONTROL_THREAD_NAME) != 0) {
--
2.33.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。