Skip to content

Commit

Permalink
rpc/server: Add a few debugging messages to be able to trace bg tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
parazyd committed Nov 11, 2023
1 parent c9e2a4e commit 0e58326
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
18 changes: 16 additions & 2 deletions src/rpc/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ pub async fn accept(
match rep {
JsonResult::Subscriber(subscriber) => {
let task = StoppableTask::new();
debug!(target: "rpc::server", "Adding background task {} to map", task.task_id);
tasks.lock().await.insert(task.clone());

// Clone what needs to go in the background
Expand Down Expand Up @@ -144,7 +145,13 @@ pub async fn accept(
drop(writer_lock);
}
},
move |_| async move { tasks_.lock().await.remove(&task_); },
move |_| async move {
debug!(
target: "rpc::server",
"Removing background task {} from map", task_.task_id,
);
tasks_.lock().await.remove(&task_);
},
Error::DetachedTaskStopped,
ex.clone(),
);
Expand All @@ -158,6 +165,7 @@ pub async fn accept(
drop(writer_lock);

let task = StoppableTask::new();
debug!(target: "rpc::server", "Adding background task {} to map", task.task_id);
tasks.lock().await.insert(task.clone());

// Clone what needs to go in the background
Expand Down Expand Up @@ -188,7 +196,13 @@ pub async fn accept(
drop(writer_lock);
}
},
move |_| async move { tasks_.lock().await.remove(&task_); },
move |_| async move {
debug!(
target: "rpc::server",
"Removing background task {} from map", task_.task_id,
);
tasks_.lock().await.remove(&task_);
},
Error::DetachedTaskStopped,
ex.clone(),
);
Expand Down
2 changes: 1 addition & 1 deletion src/system/stoppable_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub struct StoppableTask {
barrier: CondVar,

/// Used so we can keep StoppableTask in HashMap/HashSet
task_id: u32,
pub task_id: u32,
}

/// A task that can be prematurely stopped at any time.
Expand Down

0 comments on commit 0e58326

Please sign in to comment.