sync epoll: remove unnecessary judgment code

(cherry picked from commit 446e21a65aa957c0ca9463a0307754c03dd14a95)
This commit is contained in:
yinbin6 2024-10-23 11:13:18 +08:00 committed by openeuler-sync-bot
parent 023b497110
commit 16c8606fa8
3 changed files with 95 additions and 1 deletions

View File

@ -0,0 +1,54 @@
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

View File

@ -0,0 +1,34 @@
From 0cecec15dad5d4baecceb343e1803eaa9c66de26 Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng14@huawei.com>
Date: Tue, 22 Oct 2024 10:14:58 +0800
Subject: [PATCH] epoll: remove unnecessary judgment code
---
src/lstack/api/lstack_epoll.c | 11 -----------
1 file changed, 11 deletions(-)
diff --git a/src/lstack/api/lstack_epoll.c b/src/lstack/api/lstack_epoll.c
index ce3d267..acbf393 100644
--- a/src/lstack/api/lstack_epoll.c
+++ b/src/lstack/api/lstack_epoll.c
@@ -122,17 +122,6 @@ void wakeup_stack_epoll(struct protocol_stack *stack)
struct list_node *node, *temp;
list_for_each_node(node, temp, &stack->wakeup_list) {
- /* When temp is NULL, find the tail node in the wekeup_list and connect it to the back of the node */
- if (unlikely(temp == NULL)) {
- struct list_node *nod = &stack->wakeup_list;
- while (nod->prev && nod->prev != node) {
- nod = nod->prev;
- }
- nod->prev = node;
- node->next = nod;
- temp = nod;
- }
-
struct wakeup_poll *wakeup = container_of_uncheck_ptr((node - stack->stack_idx), struct wakeup_poll, wakeup_list);
if (__atomic_load_n(&wakeup->in_wait, __ATOMIC_ACQUIRE)) {
--
2.33.0

View File

@ -2,7 +2,7 @@
Name: gazelle
Version: 1.0.2
Release: 70
Release: 71
Summary: gazelle is a high performance user-mode stack
License: MulanPSL-2.0
URL: https://gitee.com/openeuler/gazelle
@ -288,6 +288,8 @@ Patch9268: 0268-bugfix-fix-gazelle-init-failed-while-setup-by-non-ro.patch
Patch9269: 0269-xdp-skip-checksum-temporarily-due-to-kernel-cannot-t.patch
Patch9270: 0270-fix-dpdk_nic_is_xdp-coredump-in-ltran-mode.patch
Patch9271: 0271-fix-the-coredump-when-gazellectl-l.patch
Patch9272: 0272-control-call-epoll_ctl-delete-fd-when-fd-close.patch
Patch9273: 0273-epoll-remove-unnecessary-judgment-code.patch
%description
%{name} is a high performance user-mode stack.
@ -329,6 +331,10 @@ install -Dpm 0640 %{_builddir}/%{name}-%{version}/src/ltran/ltran.conf %{b
%config(noreplace) %{conf_path}/ltran.conf
%changelog
* Wed Oct 23 2024 yinbin6 <yinbin8@huawei.com> - 1.0.2-71
- epoll: remove unnecessary judgment code
- control: call epoll_ctl delete fd when fd close
* Fri Oct 11 2024 yangchen <yangchen145@huawei.com> - 1.0.2-70
- fix the coredump when gazellectl -l