Skip to content

fix(qqbot): persist listener state before service stop and allow IPC timeout - #1142

Open
3316891527 wants to merge 1 commit into
AAswordman:devfrom
3316891527:fix/qqbot-lifecycle-timeout-deadlock
Open

fix(qqbot): persist listener state before service stop and allow IPC timeout#1142
3316891527 wants to merge 1 commit into
AAswordman:devfrom
3316891527:fix/qqbot-lifecycle-timeout-deadlock

Conversation

@3316891527

Copy link
Copy Markdown
Contributor

变更说明 / Description

背景与动机 / Context

QQ Bot 设置页通过 ToolPkg.ipc.call 把监听开关转发到 main runtime。宿主原先把 IPC 执行超时写死为 15 秒。杀后台后再次进入设置页关监听时,停机会串行探测残留进程,容易超过 15 秒;而 listenerEnabled=false 又写在停机成功之后,超时后配置仍为 true,application_on_create 会再次自动拉起,开关随后全部超时,只能重装。

改动内容 / Changes

  1. 宿主 IPC 超时变为可选参数,默认值保持 15 秒
    • ToolPkg.ipc.calloptions 增加可选 timeoutMs;不传时仍走原 7 参数 invokeToolPkgIpcAsync,现有插件调用不变;
    • QuickJS 按参数个数匹配原生方法,因此保留 7 参数重载,8 参数重载仅在调用方显式传入超时时使用;
    • 插件侧只暴露毫秒单位,避免同时提供秒/毫秒造成冲突。
  2. QQ Bot 监听开关先落盘再启停服务
    • qqbot_service_start / qqbot_service_stop 先写入 listenerEnabled,再启动或停止网关;
    • 停机或自动回复关闭失败时,配置仍保持已写入的开关状态,避免杀后台后死锁;
    • 设置页开关 IPC 超时提升为 45 秒。
  3. 停机扫描瘦身
    • 优先使用控制口返回的 PID,不再每次全量扫 /proc
    • 去掉逐 PID 的 cmdline inspect 串行探测,缩短杀后台后的停机路径。

验证方式与结果 / Verification

  • QQ Bot TypeScript 已通过 tsc 编译;
  • Fork 仓 GitHub Actions 中 Android Build4285f1a 已通过:https://github.com/3316891527/Operit/actions/runs/34181195962
  • Android Tests 仍红在上游存量 DeepseekProviderMediaRoleTest / XaiProviderReasoningTest 编译错误,与本次 IPC / QQ Bot 改动无关。

关联 Issue / Related Issues

Fixes #1138

检查清单 / Checklist

  • 代码符合项目规范并完成静态检查
  • 现有 ToolPkg.ipc.call 调用保持兼容(不传 timeoutMs 仍为 15 秒)
  • 监听开关先写盘再启停,避免杀后台后配置死锁

…timeout

Keep ToolPkg.ipc.call compatible with existing 7-argument native calls.
Plugins may pass optional timeoutMs; omitted calls still default to 15s.
QQ Bot writes listenerEnabled before start/stop and shortens leftover process scans so a killed-app restart cannot deadlock the settings toggle.
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