Skip to content

fix(ostool): avoid re-polling completed serial tasks - #191

Merged
ZR233 merged 2 commits into
mainfrom
codex/serial-shutdown-once
Sep 21, 2026
Merged

ZR233 merged 2 commits into
mainfrom
codex/serial-shutdown-once

Conversation

@ZR233

@ZR233 ZR233 commented Sep 21, 2026

Copy link
Copy Markdown
Member

问题

串口 WebSocket 关闭时,如果写入任务已经完成、读取任务仍然挂起,超时清理会再次等待已经完成的写入 JoinHandle,触发 Tokio 的 JoinHandle polled after completion panic。发生在板卡会话清理阶段时,该 panic 会使原本的测试结果被清理错误覆盖。

改动

  • 为两个串口任务分别保留可选的 JoinHandle 所有权;仅在等待确实完成后清空对应槽位。超时取消等待期间,尚未完成的句柄仍留在槽位中,供清理分支终止并回收。
  • 超时清理仅 abort 并等待仍在槽位中的任务,避免重复轮询已完成句柄,同时保留原先先等待两个任务、再处理任务错误的行为。
  • 新增两个确定性回归场景:写入完成而读取挂起,以及写入和读取都挂起;均检查关闭返回前任务已停止。

验证

  • 修改前定向回归稳定失败,报 JoinHandle polled after completion;修改后两个定向用例均通过。
  • cargo fmt --all -- --check
  • cargo clippy --target x86_64-unknown-linux-gnu --all-features
  • cargo build --target x86_64-unknown-linux-gnu --all-features
  • cargo test -p ostool
  • cargo test --target x86_64-unknown-linux-gnu -- --nocapture

本次未改变发布版本或变更日志,也未宣称已复现实体板卡故障;回归覆盖的是该故障日志所示的清理 panic。

@ZR233
ZR233 merged commit 3c67b18 into main Sep 21, 2026
2 checks passed
@ZR233
ZR233 deleted the codex/serial-shutdown-once branch September 21, 2026 09:25
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.

1 participant