20 Star 0 Fork 32

openEuler-RISC-V/gazelle

forked from src-openEuler/gazelle 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0033-fix-accept-check-remain-conn.patch 2.37 KB
一键复制 编辑 原始数据 按行查看 历史
jinag12 提交于 2022-03-16 22:23 . fix gazelle test issue
From 40531107531c4891defa71f899cbe96d30db9c6e Mon Sep 17 00:00:00 2001
From: wuchangsheng <wuchangsheng2@huawei.com>
Date: Wed, 16 Mar 2022 16:05:46 +0800
Subject: [PATCH 33/34] fix accept check remain conn
---
src/lstack/core/lstack_protocol_stack.c | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/src/lstack/core/lstack_protocol_stack.c b/src/lstack/core/lstack_protocol_stack.c
index 3193eeb..4a46044 100644
--- a/src/lstack/core/lstack_protocol_stack.c
+++ b/src/lstack/core/lstack_protocol_stack.c
@@ -577,17 +577,9 @@ void stack_accept(struct rpc_msg *msg)
{
int32_t fd = msg->args[MSG_ARG_0].i;
- /* listen sock attach_fd is self */
- struct lwip_sock *sock = get_socket(fd);
- if (sock == NULL) {
- msg->result = -1;
- return;
- }
- fd = sock->attach_fd;
-
int32_t accept_fd = lwip_accept(fd, msg->args[MSG_ARG_1].p, msg->args[MSG_ARG_2].p);
if (accept_fd > 0) {
- sock = get_socket(accept_fd);
+ struct lwip_sock *sock = get_socket(accept_fd);
if (sock && sock->stack) {
msg->result = accept_fd;
return;
@@ -773,13 +765,19 @@ int32_t stack_broadcast_listen(int32_t fd, int32_t backlog)
/* ergodic the protocol stack thread to find the connection, because all threads are listening */
int32_t stack_broadcast_accept(int32_t fd, struct sockaddr *addr, socklen_t *addrlen)
{
- struct lwip_sock *min_sock = NULL;
+ struct lwip_sock *sock = get_socket(fd);
+ if (sock == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ fd = sock->attach_fd;
int32_t head_fd = fd;
- int32_t min_fd = fd;
- int32_t ret = -1;
+ struct lwip_sock *min_sock = NULL;
+ int32_t min_fd = fd;
while (fd > 0) {
- struct lwip_sock *sock = get_socket(fd);
+ sock = get_socket(fd);
if (sock == NULL) {
GAZELLE_RETURN(EINVAL);
}
@@ -797,13 +795,14 @@ int32_t stack_broadcast_accept(int32_t fd, struct sockaddr *addr, socklen_t *add
fd = sock->nextfd;
}
+ int32_t ret = -1;
if (min_sock) {
ret = rpc_call_accept(min_fd, addr, addrlen);
}
- struct lwip_sock *sock = get_socket(head_fd);
if (have_accept_event(head_fd)) {
add_self_event(sock, EPOLLIN);
+ sock = get_socket(head_fd);
sock->stack->stats.accept_events++;
}
--
1.8.3.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openeuler-risc-v/gazelle.git
git@gitee.com:openeuler-risc-v/gazelle.git
openeuler-risc-v
gazelle
gazelle
master

搜索帮助