fix(daemon): enforce session idle timeout

This commit is contained in:
NianJiuZst
2026-07-10 22:36:13 +08:00
parent 913a3f80a4
commit 13279a7f56
7 changed files with 211 additions and 16 deletions
+15 -2
View File
@@ -81,11 +81,22 @@ pub struct DaemonHandle {
state: Arc<DaemonState>,
ws: WsHandle,
ipc: Option<IpcHandle>,
session_idle_task: JoinHandle<()>,
}
impl DaemonHandle {
pub(crate) fn new(state: Arc<DaemonState>, ws: WsHandle, ipc: Option<IpcHandle>) -> Self {
Self { state, ws, ipc }
pub(crate) fn new(
state: Arc<DaemonState>,
ws: WsHandle,
ipc: Option<IpcHandle>,
session_idle_task: JoinHandle<()>,
) -> Self {
Self {
state,
ws,
ipc,
session_idle_task,
}
}
pub fn state(&self) -> Arc<DaemonState> {
@@ -103,6 +114,8 @@ impl DaemonHandle {
/// Stop the WS server (and IPC if running). Returns once both join
/// handles complete.
pub async fn shutdown(self) {
self.session_idle_task.abort();
let _ = await_join(self.session_idle_task).await;
self.ws.shutdown.notify_waiters();
let _ = await_join(self.ws.task).await;
if let Some(ipc) = self.ipc {