Преглед изворни кода

rpc/server: Add a few debugging messages to be able to trace bg tasks

parazyd пре 2 година
родитељ
комит
0e58326b57
2 измењених фајлова са 17 додато и 3 уклоњено
  1. 16 2
      src/rpc/server.rs
  2. 1 1
      src/system/stoppable_task.rs

+ 16 - 2
src/rpc/server.rs

@@ -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
@@ -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(),
                 );
@@ -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
@@ -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(),
                 );

+ 1 - 1
src/system/stoppable_task.rs

@@ -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.