10 Star 0 Fork 22

src-openEuler/chrony

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-fix-finalization-for-async-resolver.patch 1.52 KB
一键复制 编辑 原始数据 按行查看 历史
xh 提交于 2025-04-15 14:22 +08:00 . sync some patches from upstream
From 08b67dba98b5dbc0184c38b3c1963dd2f00d2bd9 Mon Sep 17 00:00:00 2001
From: Miroslav Lichvar <mlichvar@redhat.com>
Date: Thu, 22 Aug 2024 09:26:59 +0200
Subject: [PATCH] ntp: fix finalization for async resolver
If an attempt to resolve addresses of an NTP server is made right before
starting the termination sequence, the asynchronous resolver thread
could read the server name when it was already freed.
Leave unresolved sources allocated in NSR_Finalise() if the async
resolver did not finish yet, at least for now. Waiting for the resolving
result or cancelling the thread would complicate the code. The scheduler
is not expected to be running at this point.
Conflict:Context adaptation
Reference:https://github.com/mlichvar/chrony/commit/08b67dba98b5dbc0184c38b3c1963dd2f00d2bd9
---
ntp_sources.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/ntp_sources.c b/ntp_sources.c
index 29c99ac..d2cd113 100644
--- a/ntp_sources.c
+++ b/ntp_sources.c
@@ -219,8 +219,13 @@ NSR_Finalise(void)
ARR_DestroyInstance(records);
ARR_DestroyInstance(pools);
- while (unresolved_sources)
- remove_unresolved_source(unresolved_sources);
+ /* Leave the unresolved sources allocated if the async resolver is running
+ to avoid reading the name from freed memory. The handler will not be
+ called as the scheduler should no longer be running at this point. */
+ if (!resolving_source) {
+ while (unresolved_sources)
+ remove_unresolved_source(unresolved_sources);
+ }
initialised = 0;
}
--
2.33.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/chrony.git
git@gitee.com:src-openeuler/chrony.git
src-openeuler
chrony
chrony
master

搜索帮助