加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0226-support-kernel-connect.patch 1.70 KB
一键复制 编辑 原始数据 按行查看 历史
From 34a090b2cfb88cb2e711d02c0f3eddf3a3656fac Mon Sep 17 00:00:00 2001
From: compile_success <980965867@qq.com>
Date: Fri, 19 Jul 2024 07:34:47 +0000
Subject: [PATCH] support kernel connect
---
src/lstack/api/lstack_epoll.c | 2 +-
src/lstack/api/lstack_wrap.c | 10 +++++++++-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/lstack/api/lstack_epoll.c b/src/lstack/api/lstack_epoll.c
index 417499b..6426de4 100644
--- a/src/lstack/api/lstack_epoll.c
+++ b/src/lstack/api/lstack_epoll.c
@@ -439,7 +439,7 @@ int32_t lstack_rtw_epoll_ctl(int32_t epfd, int32_t op, int32_t fd, struct epoll_
struct wakeup_poll *wakeup = epoll_sock->wakeup;
struct lwip_sock *sock = lwip_get_socket(fd);
- if (POSIX_IS_CLOSED(sock)) {
+ if (POSIX_IS_CLOSED(sock) || POSIX_IS_TYPE(sock, POSIX_KERNEL)) {
return posix_api->epoll_ctl_fn(epfd, op, fd, event);
}
diff --git a/src/lstack/api/lstack_wrap.c b/src/lstack/api/lstack_wrap.c
index b19990e..a6ea485 100644
--- a/src/lstack/api/lstack_wrap.c
+++ b/src/lstack/api/lstack_wrap.c
@@ -317,8 +317,16 @@ static int32_t do_connect(int32_t s, const struct sockaddr *name, socklen_t name
ret = posix_api->connect_fn(s, name, namelen);
POSIX_SET_TYPE(sock, POSIX_KERNEL);
} else {
+ /* When the socket is POSIX_LWIP_OR_KERNEL, connect to lwip first and then connect to kernel. */
ret = g_wrap_api->connect_fn(s, name, namelen);
- POSIX_SET_TYPE(sock, POSIX_LWIP);
+ if (ret == 0) {
+ POSIX_SET_TYPE(sock, POSIX_LWIP);
+ } else {
+ ret = posix_api->connect_fn(s, name, namelen);
+ if (ret == 0) {
+ POSIX_SET_TYPE(sock, POSIX_KERNEL);
+ }
+ }
}
return ret;
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化