Projects
Eulaceura:Factory
gazelle
_service:obs_scm:0272-control-call-epoll_ctl-de...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:0272-control-call-epoll_ctl-delete-fd-when-fd-close.patch of Package gazelle
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
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2