1 Star 0 Fork 32

compile_success/gazelle_3

forked from src-openEuler/gazelle 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0086-fix-fd-leak.patch 2.71 KB
一键复制 编辑 原始数据 按行查看 历史
吴昌盛 提交于 2022-10-08 22:27 . adapt ceph client
From 0e4e3a3357d5a2ffff06bf9a32bba95e207e8ff0 Mon Sep 17 00:00:00 2001
From: wu-changsheng <wuchangsheng2@huawei.com>
Date: Tue, 6 Sep 2022 16:23:58 +0800
Subject: [PATCH 01/21] fix fd leak
---
src/lstack/core/lstack_control_plane.c | 6 +++++-
src/ltran/ltran_monitor.c | 4 +++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/lstack/core/lstack_control_plane.c b/src/lstack/core/lstack_control_plane.c
index 8012fa6..7f62254 100644
--- a/src/lstack/core/lstack_control_plane.c
+++ b/src/lstack/core/lstack_control_plane.c
@@ -713,6 +713,7 @@ void control_server_thread(void *arg)
int32_t epfd = init_epoll(listenfd);
if (epfd < 0) {
+ posix_api->close_fn(listenfd);
LSTACK_LOG(ERR, LSTACK, "init_epoll failed\n");
return;
}
@@ -744,7 +745,9 @@ void control_server_thread(void *arg)
evt_array.data.fd = connfd;
evt_array.events = EPOLLIN;
- posix_api->epoll_ctl_fn(epfd, EPOLL_CTL_ADD, connfd, &evt_array);
+ if (posix_api->epoll_ctl_fn(epfd, EPOLL_CTL_ADD, connfd, &evt_array) < 0) {
+ posix_api->close_fn(connfd);
+ }
} else {
if (handle_stat_request(evt_array.data.fd) < 0) {
posix_api->close_fn(evt_array.data.fd);
@@ -761,6 +764,7 @@ void control_client_thread(void *arg)
epfd = init_epoll(sockfd);
if (epfd < 0) {
+ posix_api->close_fn(sockfd);
LSTACK_LOG(ERR, LSTACK, "control_thread fail\n");
return;
}
diff --git a/src/ltran/ltran_monitor.c b/src/ltran/ltran_monitor.c
index dfda93f..7da65ea 100644
--- a/src/ltran/ltran_monitor.c
+++ b/src/ltran/ltran_monitor.c
@@ -188,6 +188,7 @@ static int32_t gazelle_ctl_init(void)
ret = gazelle_ep_event_init(&event_dfx, GAZELLE_DFX_SERVER_FD, listenfd);
if (ret != GAZELLE_OK) {
+ close(listenfd);
return GAZELLE_ERR;
}
@@ -207,6 +208,7 @@ static int32_t gazelle_ctl_init(void)
ret = gazelle_ep_event_init(&event_reg, GAZELLE_REG_SERVER_FD, listenfd);
if (ret != GAZELLE_OK) {
+ close(listenfd);
sockfd_data_free(event_dfx.data.ptr);
return GAZELLE_ERR;
}
@@ -283,7 +285,6 @@ static void dfx_server_msg_proc(uint32_t events, struct sockfd_data *data)
if (ret < 0) {
LTRAN_ERR("epoll_ctl ERROR, errno: %d. ret=%d.\n", errno, ret);
sockfd_data_free(event.data.ptr);
- close(conn_fd);
return;
}
}
@@ -421,6 +422,7 @@ static void reg_server_msg_proc(uint32_t events, struct sockfd_data *data)
event.events = EPOLLIN;
if (event.data.ptr == NULL) {
LTRAN_ERR("alloc sockfd_data ERROR\n");
+ close(conn_fd);
return;
}
--
2.23.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/compile_success/gazelle_3.git
git@gitee.com:compile_success/gazelle_3.git
compile_success
gazelle_3
gazelle_3
master

搜索帮助