diff --git a/src/core/bot_actions.rs b/src/core/bot_actions.rs index 235637e..37f2445 100644 --- a/src/core/bot_actions.rs +++ b/src/core/bot_actions.rs @@ -56,7 +56,7 @@ impl ExecBodyParams { let curr_act = Arc::clone(&self.curr_act); let parent_act_lock = curr_act.read().await; let act = &(*parent_act_lock); - match act { + let out = match act { BotAction::C(_) => { // let temp = c.module.clone(); // Some(temp) @@ -72,10 +72,20 @@ impl ExecBodyParams { // let temp = r.module.clone(); // Some(temp) dbg!("Core > ExecBodyParams > GetChannels - routine identified"); - Some(r.read().await.channel.clone()) + dbg!(">> BotActionAR - RwLock from botmodules.rs::929:46 - current_readers = 1 "); + dbg!(">> RoutineAR - RwLock from botmodules.rs::1261:32 - current_readers = 1"); + dbg!(">> join_handle - RwLock from botmodules.rs::1226:46 - current_readers = 0"); + dbg!(">> BotInstanceAR - RwLock from botinstance.rs::150:28 - current_readers = 3 "); + // => 03.30 - Just before deadlock + let out = Some(r.read().await.channel.clone()); + + // => 03.30 - This isn't reached because of the Deadlock + dbg!(">> Just after Potential Deadlock Lock"); + out } // _ => None - } + }; + out } diff --git a/src/core/botmodules.rs b/src/core/botmodules.rs index b3c8a5f..65d902a 100644 --- a/src/core/botmodules.rs +++ b/src/core/botmodules.rs @@ -1221,9 +1221,11 @@ impl Routine { { // Recommendation to ensure a clean update is to use one write() lock that was awaited // - We can isolate the write lock by ensuring it's in it's own block - let mut lock = trg_routine_arout.write().await; + // => 03.30 - involved with Problem Deadlock Current Readers = 0 + let mut lock = trg_routine_arout.write().await; lock.join_handle = Some(Arc::new(RwLock::new(join_handle))); lock.internal_signal = RoutineSignal::Started; + drop(lock); // => 03.30 - added this to try to address Deadlock issue } trg_routine_arout.write().await.internal_signal = RoutineSignal::Started; @@ -1236,6 +1238,11 @@ impl Routine { // (routine.exec_body)(params).await; // } + + // fn (){ + + // } + async fn loopbody(&mut self) // [x] => 03.27 - COMPLETED { @@ -1248,14 +1255,18 @@ impl Routine { ); Log::flush(); - - let self_ar = Arc::new(RwLock::new(self)); + + // => 03.30 - involved with Problem Deadlock Current Readers = 1 + // - Below self appears to be a Arc> + let self_ar = Arc::new(RwLock::new(self)); + { let mut mutlock = self_ar.write().await; mutlock.parent_params.parent_act = Some(mutlock.parent_params.curr_act.clone()); mutlock.parent_params.curr_act = mutlock.self_act_ar.to_owned().unwrap(); + drop(mutlock); // => 03.30 - Added to address Deadlock issue } dbg!("Core > Before Guards"); @@ -1275,6 +1286,9 @@ impl Routine { }; dbg!("Core > Guarding & Executing Child Execution Body"); + dbg!(">> BotActionAR - RwLock from botmodules.rs::929:46 - current_readers = 0 "); + dbg!(">> RoutineAR - RwLock from botmodules.rs::1261:32 - current_readers = Not Listed"); + dbg!(">> BotInstanceAR - RwLock from botinstance.rs::150:28 - current_readers = 3 "); { let guard2 = self_ar.read().await;