代码拉取完成,页面将自动刷新
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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。