1 Star 0 Fork 32

Ren Zhijie/gazelle

forked from src-openEuler/gazelle 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0096-use-default-nonblock-mode.patch 2.72 KB
一键复制 编辑 原始数据 按行查看 历史
From 47ab261c2b533975a59b34f06da0ccf83692bb78 Mon Sep 17 00:00:00 2001
From: compile_success <980965867@qq.com>
Date: Tue, 26 Dec 2023 16:53:58 +0000
Subject: [PATCH] use default nonblock mode
---
src/lstack/core/lstack_cfg.c | 12 ++++++++++++
src/lstack/core/lstack_protocol_stack.c | 5 ++++-
src/lstack/include/lstack_cfg.h | 1 +
3 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/src/lstack/core/lstack_cfg.c b/src/lstack/core/lstack_cfg.c
index a292070..d9c23fb 100644
--- a/src/lstack/core/lstack_cfg.c
+++ b/src/lstack/core/lstack_cfg.c
@@ -80,6 +80,7 @@ static int32_t parse_nic_rxqueue_size(void);
static int32_t parse_nic_txqueue_size(void);
static int32_t parse_stack_thread_mode(void);
static int32_t parse_nic_vlan_mode(void);
+static int32_t parse_defaule_nonblock_mode(void);
#define PARSE_ARG(_arg, _arg_string, _default_val, _min_val, _max_val, _ret) \
do { \
@@ -142,6 +143,7 @@ static struct config_vector_t g_config_tbl[] = {
{ "nic_txqueue_size", parse_nic_txqueue_size},
{ "stack_thread_mode", parse_stack_thread_mode },
{ "nic_vlan_mode", parse_nic_vlan_mode },
+ { "nonblock_mode", parse_defaule_nonblock_mode },
{ NULL, NULL }
};
@@ -1280,3 +1282,13 @@ static int32_t parse_nic_vlan_mode(void)
return ret;
}
+static int32_t parse_defaule_nonblock_mode(void)
+{
+ int32_t ret;
+ PARSE_ARG(g_config_params.nonblock_mode, "nonblock_mode", 1, 0, 1, ret);
+ if (ret != 0) {
+ LSTACK_PRE_LOG(LSTACK_ERR, "cfg: invalid nonblock mode value %d. only support 0 or 1\n", \
+ g_config_params.nonblock_mode);
+ }
+ return ret;
+}
diff --git a/src/lstack/core/lstack_protocol_stack.c b/src/lstack/core/lstack_protocol_stack.c
index 9158d20..a000224 100644
--- a/src/lstack/core/lstack_protocol_stack.c
+++ b/src/lstack/core/lstack_protocol_stack.c
@@ -1287,7 +1287,10 @@ int32_t stack_broadcast_accept4(int32_t fd, struct sockaddr *addr, socklen_t *ad
int32_t stack_broadcast_accept(int32_t fd, struct sockaddr *addr, socklen_t *addrlen)
{
- return stack_broadcast_accept4(fd, addr, addrlen, 0);
+ if (get_global_cfg_params()->nonblock_mode)
+ return stack_broadcast_accept4(fd, addr, addrlen, O_NONBLOCK);
+ else
+ return stack_broadcast_accept4(fd, addr, addrlen, 0);
}
static void stack_all_fds_close(void)
diff --git a/src/lstack/include/lstack_cfg.h b/src/lstack/include/lstack_cfg.h
index a6bdfd5..82e96d8 100644
--- a/src/lstack/include/lstack_cfg.h
+++ b/src/lstack/include/lstack_cfg.h
@@ -118,6 +118,7 @@ struct cfg_params {
bool udp_enable;
struct cfg_nic_params nic;
bool stack_mode_rtc;
+ bool nonblock_mode;
};
struct cfg_params *get_global_cfg_params(void);
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/byterzj/gazelle.git
git@gitee.com:byterzj/gazelle.git
byterzj
gazelle
gazelle
master

搜索帮助