14 Star 5 Fork 32

src-openEuler/gazelle

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0272-control-call-epoll_ctl-delete-fd-when-fd-close.patch 2.01 KB
一键复制 编辑 原始数据 按行查看 历史
yinbin6 提交于 2024-10-23 11:13 +08:00 . sync epoll: remove unnecessary judgment code
From 2c8bf41f4adf425afc668b77c2a792abcdd98c5b Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng14@huawei.com>
Date: Thu, 17 Oct 2024 19:16:55 +0800
Subject: [PATCH] control: call epoll_ctl delete fd when fd close
---
src/lstack/core/lstack_control_plane.c | 8 ++++++++
src/lstack/core/lstack_lwip.c | 4 ++++
2 files changed, 12 insertions(+)
diff --git a/src/lstack/core/lstack_control_plane.c b/src/lstack/core/lstack_control_plane.c
index 11f5129..bf34693 100644
--- a/src/lstack/core/lstack_control_plane.c
+++ b/src/lstack/core/lstack_control_plane.c
@@ -778,6 +778,12 @@ void control_server_thread(void *arg)
}
if ((evt_array.events & EPOLLERR) || (evt_array.events & EPOLLHUP)) {
+ /*
+ * if app call fork and child process inherits the fd,
+ * close fd cannot ensure that fd is removed from the epoll,
+ * so epoll_ctl_del need to be called.
+ */
+ posix_api->epoll_ctl_fn(epfd, EPOLL_CTL_DEL, evt_array.data.fd, NULL);
posix_api->close_fn(evt_array.data.fd);
continue;
}
@@ -795,6 +801,8 @@ void control_server_thread(void *arg)
}
} else {
if (handle_stat_request(evt_array.data.fd) < 0) {
+ /* same as the comment above */
+ posix_api->epoll_ctl_fn(epfd, EPOLL_CTL_DEL, evt_array.data.fd, NULL);
posix_api->close_fn(evt_array.data.fd);
}
}
diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c
index cb0964b..bb261d2 100644
--- a/src/lstack/core/lstack_lwip.c
+++ b/src/lstack/core/lstack_lwip.c
@@ -185,6 +185,10 @@ int do_lwip_init_sock(int32_t fd)
return 0;
}
+ if (sock->recv_ring != NULL || sock->send_ring != NULL) {
+ LSTACK_LOG(ERR, LSTACK, "socket(%d) not close but open again?\n", fd);
+ }
+
reset_sock_data(sock);
sock->recv_ring = gazelle_ring_create_fast("sock_recv", SOCK_RECV_RING_SIZE, RING_F_SP_ENQ | RING_F_SC_DEQ);
--
2.33.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/gazelle.git
git@gitee.com:src-openeuler/gazelle.git
src-openeuler
gazelle
gazelle
master

搜索帮助