Skip to content

refactor(rtsp): defer client session reaping#804

Draft
qiin2333 wants to merge 1 commit into
agent/asio-session-coordinatorfrom
codex/defer-client-session-reaping
Draft

refactor(rtsp): defer client session reaping#804
qiin2333 wants to merge 1 commit into
agent/asio-session-coordinatorfrom
codex/defer-client-session-reaping

Conversation

@qiin2333

@qiin2333 qiin2333 commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

依赖

杂鱼,这次改了什么呀

  • 让认证客户端的 /cancel 只按证书 UUID 标记所属会话为 draining,并立即唤醒 RTSP reaper,不再在 HTTPS 请求线程里同步 join()
  • 把会话 join、应用终止和显示恢复保留在同一个有序清理阶段,避免跨线程同时访问进程与显示生命周期
  • 增加 launch/resume 清理闸门:清理运行时新请求等待;新 ticket 或 stream 成功接管时,旧的空闲清理意图会被取消
  • 新增独立并发单测,覆盖 launch 在途、清理运行、新会话接管和 host 不再空闲四类竞态

为什么要这样改

之前客户端 cancel 会在 HTTPS 路径里持有 session registry 锁并等待视频、音频和控制线程结束,最坏会触及 10 秒 hang watchdog。多会话压力较高时,这会把协议响应和资源回收绑在一起,客户端就更容易感觉成“退了以后卡住啦”。

这一层仍保持现有所有权和最后会话语义,只拆开“发停止信号”和“完成资源回收”,不把编码、发包或阻塞 join 塞进 Asio strand。

风险和兼容性

  • /cancel 的 200 响应会早于最终线程 join;如果客户端马上 launch/resume,闸门会等待清理完成,因此不会复用正在终止的应用
  • 其他客户端仍活跃或有待认领 ticket 时,不会终止共享应用,也不会恢复显示
  • 编码与网络数据面没有迁移,回滚边界保持很小

验证

  • git diff --check
  • range-diff 显示本提交重放前后完全等价
  • 使用现有 Windows -Werror 编译参数检查 nvhttp.cpprtsp.cppsession_cleanup_gate.cpp 和清理闸门测试
  • 完整 Windows 构建与原生测试重新交给本分支 CI

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 25d0ef5b-57d6-467d-85ab-cac017ef96f2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/defer-client-session-reaping

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@qiin2333
qiin2333 force-pushed the agent/asio-session-coordinator branch from d7e67e8 to fab26ad Compare July 13, 2026 10:38
@qiin2333
qiin2333 force-pushed the codex/defer-client-session-reaping branch from 2fc271e to 09fa549 Compare July 13, 2026 10:39
@qiin2333
qiin2333 force-pushed the agent/asio-session-coordinator branch from fab26ad to 414fcf2 Compare July 15, 2026 02:54
@qiin2333
qiin2333 force-pushed the codex/defer-client-session-reaping branch from 09fa549 to 817da99 Compare July 15, 2026 02:55
Make authenticated client cancel signal matching sessions and wake the RTSP reaper instead of joining worker threads on the HTTPS request path. Coordinate deferred host cleanup with concurrent launch and resume operations, and cover the cleanup gate with focused concurrency tests.
@qiin2333
qiin2333 force-pushed the agent/asio-session-coordinator branch from 414fcf2 to f217d86 Compare July 15, 2026 04:47
@qiin2333
qiin2333 force-pushed the codex/defer-client-session-reaping branch from 817da99 to 46dbb84 Compare July 15, 2026 04:47
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