Просмотр исходного кода

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

parazyd 2 лет назад
Родитель
Сommit
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 {
         match rep {
             JsonResult::Subscriber(subscriber) => {
             JsonResult::Subscriber(subscriber) => {
                 let task = StoppableTask::new();
                 let task = StoppableTask::new();
+                debug!(target: "rpc::server", "Adding background task {} to map", task.task_id);
                 tasks.lock().await.insert(task.clone());
                 tasks.lock().await.insert(task.clone());
 
 
                 // Clone what needs to go in the background
                 // Clone what needs to go in the background
@@ -144,7 +145,13 @@ pub async fn accept(
                             drop(writer_lock);
                             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,
                     Error::DetachedTaskStopped,
                     ex.clone(),
                     ex.clone(),
                 );
                 );
@@ -158,6 +165,7 @@ pub async fn accept(
                 drop(writer_lock);
                 drop(writer_lock);
 
 
                 let task = StoppableTask::new();
                 let task = StoppableTask::new();
+                debug!(target: "rpc::server", "Adding background task {} to map", task.task_id);
                 tasks.lock().await.insert(task.clone());
                 tasks.lock().await.insert(task.clone());
 
 
                 // Clone what needs to go in the background
                 // Clone what needs to go in the background
@@ -188,7 +196,13 @@ pub async fn accept(
                             drop(writer_lock);
                             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,
                     Error::DetachedTaskStopped,
                     ex.clone(),
                     ex.clone(),
                 );
                 );

+ 1 - 1
src/system/stoppable_task.rs

@@ -36,7 +36,7 @@ pub struct StoppableTask {
     barrier: CondVar,
     barrier: CondVar,
 
 
     /// Used so we can keep StoppableTask in HashMap/HashSet
     /// 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.
 /// A task that can be prematurely stopped at any time.