1 Star 0 Fork 32

misaka00251/gazelle

forked from src-openEuler/gazelle 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0072-support-epoll-oneshot.patch 1.97 KB
一键复制 编辑 原始数据 按行查看 历史
吴昌盛 提交于 2022-07-26 22:08 . support epoll oneshot
From 8870ece28ab3b467c43c1231177d826fd7907801 Mon Sep 17 00:00:00 2001
From: wu-changsheng <wuchangsheng2@huawei.com>
Date: Tue, 26 Jul 2022 21:03:23 +0800
Subject: [PATCH] support epoll oneshot
---
src/lstack/api/lstack_epoll.c | 13 +++++++++++++
src/lstack/core/lstack_lwip.c | 1 -
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/lstack/api/lstack_epoll.c b/src/lstack/api/lstack_epoll.c
index 310a0e7..963a696 100644
--- a/src/lstack/api/lstack_epoll.c
+++ b/src/lstack/api/lstack_epoll.c
@@ -291,6 +291,12 @@ static int32_t epoll_lwip_event(struct wakeup_poll *wakeup, struct epoll_event *
list_for_each_safe(node, temp, &wakeup->event_list) {
struct lwip_sock *sock = container_of(node, struct lwip_sock, event_list);
+
+ if (sock->epoll_events == 0) {
+ list_del_node_null(&sock->event_list);
+ continue;
+ }
+
if (sock->conn && sock->conn->acceptmbox) {
accept_num++;
}
@@ -299,6 +305,13 @@ static int32_t epoll_lwip_event(struct wakeup_poll *wakeup, struct epoll_event *
list_del_node_null(&sock->event_list);
}
+ /* EPOLLONESHOT: generate event after epoll_ctl add/mod event again
+ epoll_event set 0 avoid generating event util epoll_ctl set epoll_event a valu */
+ if (sock->epoll_events & EPOLLONESHOT) {
+ list_del_node_null(&sock->event_list);
+ sock->epoll_events = 0;
+ }
+
events[event_num].events = sock->events;
events[event_num].data = sock->ep_data;
event_num++;
diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c
index 4c2f0ea..80d781f 100644
--- a/src/lstack/core/lstack_lwip.c
+++ b/src/lstack/core/lstack_lwip.c
@@ -75,7 +75,6 @@ static void reset_sock_data(struct lwip_sock *sock)
sock->stack = NULL;
sock->wakeup = NULL;
sock->listen_next = NULL;
- sock->wait_close = false;
sock->epoll_events = 0;
sock->events = 0;
--
2.23.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/misaka00251/gazelle.git
git@gitee.com:misaka00251/gazelle.git
misaka00251
gazelle
gazelle
master

搜索帮助