mirror of
https://github.com/Tencent/BrowserSkill.git
synced 2026-09-10 13:01:23 +08:00
fix(daemon): enforce session idle timeout
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user