代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/gazelle 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From be28f36adfebb0e5f7f2340638120a19f5b2eaa6 Mon Sep 17 00:00:00 2001
From: hankangkang <hankangkang5@huawei.com>
Date: Thu, 14 Nov 2024 20:16:14 +0800
Subject: [PATCH] suport kernel accept for openGauss
---
src/lstack/api/lstack_wrap.c | 34 ++++++++++++++++++++++++++++++----
1 file changed, 30 insertions(+), 4 deletions(-)
diff --git a/src/lstack/api/lstack_wrap.c b/src/lstack/api/lstack_wrap.c
index 66cea51..6ab31f6 100644
--- a/src/lstack/api/lstack_wrap.c
+++ b/src/lstack/api/lstack_wrap.c
@@ -14,6 +14,7 @@
#include <ifaddrs.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
+#include <fcntl.h>
#include <linux/if_xdp.h>
#include <lwip/lwipgz_posix_api.h>
@@ -102,14 +103,22 @@ static inline int32_t do_accept(int32_t s, struct sockaddr *addr, socklen_t *add
return posix_api->accept_fn(s, addr, addrlen);
}
- int32_t fd = g_wrap_api->accept_fn(s, addr, addrlen);
+ int fd = 0;
+ struct lwip_sock *sock = lwip_get_socket(s);
+ if (POSIX_HAS_TYPE(sock, POSIX_KERNEL)) {
+ fd = posix_api->accept4_fn(s, addr, addrlen, SOCK_NONBLOCK);
+ if (fd >= 0) {
+ return fd;
+ }
+ }
+
+ fd = g_wrap_api->accept_fn(s, addr, addrlen);
if (fd >= 0) {
- struct lwip_sock *sock = lwip_get_socket(fd);
+ sock = lwip_get_socket(fd);
POSIX_SET_TYPE(sock, POSIX_LWIP);
- return fd;
}
- return posix_api->accept_fn(s, addr, addrlen);
+ return fd;
}
static int32_t do_accept4(int32_t s, struct sockaddr *addr, socklen_t *addrlen, int32_t flags)
@@ -132,6 +141,22 @@ static int32_t do_accept4(int32_t s, struct sockaddr *addr, socklen_t *addrlen,
return posix_api->accept4_fn(s, addr, addrlen, flags);
}
+static inline int sock_set_nonblocking(int fd)
+{
+ int flags = posix_api->fcntl_fn(fd, F_GETFL, 0);
+ if (flags == -1) {
+ LSTACK_LOG(ERR, LSTACK, " get block status faild errno %d.\n", errno);
+ return -1;
+ }
+ // set nonblock
+ flags |= O_NONBLOCK;
+ if (posix_api->fcntl_fn(fd, F_SETFL, flags) == -1) {
+ LSTACK_LOG(ERR, LSTACK, " set non_block status faild errno %d.\n", errno);
+ return -1;
+ }
+ return 0;
+}
+
static int kernel_bind_process(int32_t s, const struct sockaddr *name, socklen_t namelen)
{
struct lwip_sock *sock = lwip_get_socket(s);
@@ -165,6 +190,7 @@ static int kernel_bind_process(int32_t s, const struct sockaddr *name, socklen_t
((struct sockaddr_in *)name)->sin_port = kerneladdr.sin_port;
}
/* not sure POSIX_LWIP or POSIX_KERNEL */
+ sock_set_nonblocking(s);
} else {
POSIX_SET_TYPE(sock, POSIX_LWIP);
LSTACK_LOG(ERR, LSTACK, "kernel bind failed ret %d errno %d sa_family %u times %u\n",
--
2.33.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。