🔴 [H7] 文件监控回调中使用阻塞 send #7

Closed
opened 2026-06-03 13:52:51 +08:00 by dailz · 0 comments
Owner

文件: core/watcher/file_watcher.rs:65-98
分类: 并发 / 通道

问题: notify 回调在 notify 内部线程中调用阻塞 tx.send(),通道容量 100。如果消费者停止消费(UI 冻结),回调会无限阻塞,导致 Drop/shutdown 延迟,后续事件全部丢失。

let (tx, rx) = bounded(100);
// 在 notify 回调中:
let _ = tx.send(FileEvent::Removed);  // ← 可能阻塞 notify 线程

建议修复: 改用 try_send,或使用非阻塞/无界通道加显式背压策略。

**文件**: `core/watcher/file_watcher.rs:65-98` **分类**: 并发 / 通道 **问题**: notify 回调在 notify 内部线程中调用阻塞 `tx.send()`,通道容量 100。如果消费者停止消费(UI 冻结),回调会**无限阻塞**,导致 Drop/shutdown 延迟,后续事件全部丢失。 ```rust let (tx, rx) = bounded(100); // 在 notify 回调中: let _ = tx.send(FileEvent::Removed); // ← 可能阻塞 notify 线程 ``` **建议修复**: 改用 `try_send`,或使用非阻塞/无界通道加显式背压策略。
dailz added the area/concurrencybugseverity/high labels 2026-06-03 13:52:51 +08:00
dailz closed this issue 2026-06-04 14:33:49 +08:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dailz/logViewer#7