fix: resolve lastore-daemon service registration status check issue#298
Merged
Conversation
The update service registration was failing to properly check system status after the lastore-daemon became valid. Previously, the wait service timer was not being stopped when the check system was called from the timer callback, causing potential race conditions. Additionally, the doCheckSystem method contained the D-Bus service validity check, which was moved to a new checkSystem method that properly handles the waiting logic before calling doCheckSystem. Log: Fixed system check after lastore-daemon service registration Influence: 1. Test system check functionality when lastore-daemon service is already valid 2. Test system check when lastore-daemon service is not yet available and becomes valid later 3. Verify that wait service timer is properly stopped when service becomes valid 4. Verify that system check is not triggered twice due to timer race conditions 5. Test upgrade workflow end-to-end to ensure proper system check execution fix: 修复lastore-daemon服务注册后获取状态问题 更新服务注册时,在lastore-daemon变为有效后未能正确检查系统状态。之前从 定时器回调调用checkSystem时没有停止等待服务定时器,可能导致竞态条件。 此外,doCheckSystem方法包含了D-Bus服务有效性检查,现在将其移动到新的 checkSystem方法中,该方法在调用doCheckSystem之前正确处理等待逻辑。 Log: 修复lastore-daemon服务注册后的系统检查 Influence: 1. 测试lastore-daemon服务已生效时的系统检查功能 2. 测试lastore-daemon服务尚未就绪后变为可用时的系统检查 3. 验证服务可用时等待服务定时器是否正常停止 4. 验证不会因定时器竞态条件导致系统检查被触发两次 5. 测试完整升级流程,确保系统检查正常执行 PMS: BUG-361789 Change-Id: I5de82d873a864673eb06482f09109c32f10cdc8f
deepin pr auto review你好!我是CodeGeeX,很高兴为你审查这段代码。 本次代码变更主要进行了以下几项重构和修复:
整体来看,这次重构提升了代码的内聚性和逻辑清晰度,修复了潜在的计时器泄漏问题。下面我将从语法逻辑、代码质量、代码性能和代码安全四个维度为你提供详细的审查意见和改进建议: 一、 语法与逻辑
二、 代码质量
三、 代码性能
四、 代码安全
综合修改建议示例基于以上分析,我为你提供一份优化后的代码片段参考: src/dde-update/updateworker.cpp void UpdateWorker::checkSystem(int updateMode, UpdateModel::CheckSystemStage stage)
{
qCInfo(logUpdateModal) << "checkSystem called, checking interface validity...";
if (!m_dbusProxy->managerInterIsValid()) {
qCWarning(logUpdateModal) << "org.deepin.dde.Lastore1 interface is invalid, wait for service to be valid";
m_waitingToCheckSystem = true;
// 建议:如果业务要求每次调用重置定时器,则直接 start;如果要求不重置,需加 isActive 判断
m_waitServiceTimer->start();
return;
}
doCheckSystem(updateMode, stage);
}
void UpdateWorker::doCheckSystem(int updateMode, UpdateModel::CheckSystemStage stage)
{
// 统一日志格式,避免与 checkSystem 打印重复信息
qCInfo(logUpdateModal) << "doCheckSystem: update mode:" << updateMode << ", check system stage:" << stage;
QDBusPendingReply<QDBusObjectPath> reply = m_dbusProxy->CheckUpgrade(updateMode, static_cast<int>(stage));
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
connect(watcher, &QDBusPendingCallWatcher::finished, this, [this, watcher] {
// 安全提醒:确保在此处有如下类似逻辑防止内存泄漏
// if (watcher->isError()) {
// qCWarning(...) << watcher->error().message();
// } else {
// ...
// }
watcher->deleteLater();
});
// ... 其他逻辑
}src/dde-update/updateworker.h // 建议补充注释说明接口职责区分
void checkSystem(int updateMode, UpdateModel::CheckSystemStage stage); // 包含服务有效性检查及等待逻辑
void doCheckSystem(int updateMode, UpdateModel::CheckSystemStage stage); // 直接执行DBus检查调用版权声明建议修改为: // SPDX-FileCopyrightText: 2022 - present UnionTech Software Technology Co., Ltd.希望这些审查意见对你有所帮助!如果还有其他代码需要审查,随时告诉我。 |
mhduiy
approved these changes
May 19, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mhduiy, xionglinlin The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The update service registration was failing to properly check system status after the lastore-daemon became valid. Previously, the wait service timer was not being stopped when the check system was called from the timer callback, causing potential race conditions. Additionally, the doCheckSystem method contained the D-Bus service validity check, which was moved to a new checkSystem method that properly handles the waiting logic before calling doCheckSystem.
Log: Fixed system check after lastore-daemon service registration
Influence:
fix: 修复lastore-daemon服务注册后获取状态问题
更新服务注册时,在lastore-daemon变为有效后未能正确检查系统状态。之前从
定时器回调调用checkSystem时没有停止等待服务定时器,可能导致竞态条件。
此外,doCheckSystem方法包含了D-Bus服务有效性检查,现在将其移动到新的
checkSystem方法中,该方法在调用doCheckSystem之前正确处理等待逻辑。
Log: 修复lastore-daemon服务注册后的系统检查
Influence:
PMS: BUG-361789
Change-Id: I5de82d873a864673eb06482f09109c32f10cdc8f