Skip to content

fix: fix daemon fail to init#222

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:develop/snipefrom
wangrong1069:pr0623
Jun 23, 2026
Merged

fix: fix daemon fail to init#222
deepin-bot[bot] merged 1 commit into
linuxdeepin:develop/snipefrom
wangrong1069:pr0623

Conversation

@wangrong1069

Copy link
Copy Markdown
Contributor

In the current implementation, the index verification operation is located between the event listening operation and the event receiving operation. If the index verification operation takes too long, the buffer may overflow due to storing a large number of file events, causing errors in event receiving and ultimately leading to daemon initialization failure.
The current solution is to move the event listening operation after the index verification operation.

在当前的实现中, 索引校验操作位于事件监听操作和事件接收操作之间,
如果索引校验操作耗时过长, 就可能导致缓冲区因保存了大量的文件事件
而发生溢出, 这会导致事件接收时报错, 进而导致 daemon 初始化失败.
当前的修复方案是将事件监听操作放到索引校验操作之后.

Log: 修复性能差的系统上索引更新失败
PMS: BUG-367093

In the current implementation, the index verification operation is
located between the event listening operation and the event receiving
operation. If the index verification operation takes too long, the
buffer may overflow due to storing a large number of file events,
causing errors in event receiving and ultimately leading to daemon
initialization failure.
The current solution is to move the event listening operation after
the index verification operation.

在当前的实现中, 索引校验操作位于事件监听操作和事件接收操作之间,
如果索引校验操作耗时过长, 就可能导致缓冲区因保存了大量的文件事件
而发生溢出, 这会导致事件接收时报错, 进而导致 daemon 初始化失败.
当前的修复方案是将事件监听操作放到索引校验操作之后.

Log: 修复性能差的系统上索引更新失败
PMS: BUG-367093

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @wangrong1069, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:88分

■ 【总体评价】

代码修复了监听器与处理器实例化顺序导致的逻辑缺陷,但存在变量命名拼写错误
逻辑正确但因拼写不规范扣12分

■ 【详细分析】

  • 1.语法逻辑(完全正确)✓

修改将 event_listenser 的实例化移至 default_event_handler 之后,确保在清空索引目录的操作完成后再启动文件系统事件监听,彻底消除了监听器捕获到无意义清空事件的竞态条件缺陷,逻辑闭环完整

  • 2.代码质量(一般)✕

在 main 函数中使用的变量名 listenser 存在明显的英文拼写错误,正确拼写应为 listener,虽然不影响编译和运行,但降低了代码可读性和专业度
潜在问题:拼写错误会误导后续维护人员,且在全局搜索 listener 关键字时容易遗漏该变量
建议:将变量名 listenser 重命名为 listener,同时修改后续调用处的名称

  • 3.代码性能(高效)✓

仅调整了对象在栈上的构造顺序,未引入任何额外的系统调用、内存分配或算法开销,对运行时性能无负面影响

  • 4.代码安全(存在0个安全漏洞)✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
调整实例化顺序属于纯逻辑修复,未引入任何外部输入处理、权限变更或内存越界等安全风险

  • 建议:保持当前的安全编码实践

■ 【改进建议代码示例】

diff --git a/src/daemon/src/main.cpp b/src/daemon/src/main.cpp
index bd84c5b..4036b10 100644
--- a/src/daemon/src/main.cpp
+++ b/src/daemon/src/main.cpp
@@ -100,11 +100,11 @@ int main(int argc, char* argv[]) {
     detect_last_time_quit_status();
     set_running_flag();
 
-    event_listenser listenser;
     print_event_handler_config(event_handler_config);
     default_event_handler handler(event_handler_config);
     // default_event_handler 实例化时, 可能会清空索引目录, 这里重新设置 running 标志
     set_running_flag();
-    event_listenser listenser;
+    event_listenser listener;
-    listenser.set_handler([&handler](fs_event *event) {
+    listener.set_handler([&handler](fs_event *event) {
         handler.handle(event);
     });

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: lzwind, wangrong1069

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@wangrong1069

Copy link
Copy Markdown
Contributor Author

/merge

@deepin-bot deepin-bot Bot merged commit a833451 into linuxdeepin:develop/snipe Jun 23, 2026
22 checks passed
@wangrong1069 wangrong1069 deleted the pr0623 branch June 23, 2026 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants