addl debug

This commit is contained in:
ModulatingForce 2024-03-30 19:25:07 -04:00
parent 745ac91522
commit 4719b93ce5
3 changed files with 72 additions and 12 deletions

View file

@ -52,10 +52,33 @@ impl ExecBodyParams {
pub async fn get_channel(&self) -> Option<Channel> { pub async fn get_channel(&self) -> Option<Channel> {
dbg!("Core > ExecBodyParams > GetChannels START");
dbg!("!! [x] Document - After SUCCESS message was sent to chat");
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 = 2");
let curr_act = Arc::clone(&self.curr_act); let curr_act = Arc::clone(&self.curr_act);
let parent_act_lock = curr_act.read().await; let curr_act_lock = curr_act.read().await;
let act = &(*parent_act_lock);
dbg!("Core > ExecBodyParams > After Creating ExecBodyParams.current_act.read() Guard ");
dbg!("!! [x] Document - After SUCCESS message was sent to chat");
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 = 2");
let act = &(*curr_act_lock);
dbg!("Core > ExecBodyParams > Using the Read Guard ");
dbg!("!! [x] Document - After SUCCESS message was sent to chat");
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 = Not Listed ");
dbg!(">> BotInstanceAR - RwLock from botinstance.rs::150:28 - current_readers = 2");
let out = match act { let out = match act {
BotAction::C(_) => { BotAction::C(_) => {
// let temp = c.module.clone(); // let temp = c.module.clone();
@ -72,12 +95,22 @@ impl ExecBodyParams {
// let temp = r.module.clone(); // let temp = r.module.clone();
// Some(temp) // Some(temp)
dbg!("Core > ExecBodyParams > GetChannels - routine identified"); dbg!("Core > ExecBodyParams > GetChannels - routine identified");
dbg!(">> BotActionAR - RwLock from botmodules.rs::929:46 - current_readers = 1 "); dbg!("!! [x] Document");
dbg!(">> RoutineAR - RwLock from botmodules.rs::1261:32 - current_readers = 1"); dbg!(">> BotActionAR - RwLock from botmodules.rs::930:46 - current_readers = 2");
dbg!(">> RoutineAR - RwLock from botmodules.rs::1262:32 - current_readers = 1");
dbg!(">> join_handle - RwLock from botmodules.rs::1226:46 - current_readers = 0"); dbg!(">> join_handle - RwLock from botmodules.rs::1226:46 - current_readers = 0");
dbg!(">> BotInstanceAR - RwLock from botinstance.rs::150:28 - current_readers = 3 "); dbg!(">> BotInstanceAR - RwLock from botinstance.rs::150:28 - current_readers = 1");
// => 03.30 - Just before deadlock // => 03.30 - Just before deadlock
let out = Some(r.read().await.channel.clone()); // dbg!("ISSUE : RoutineAR - RwLock from botmodules.rs::1261:32 - current_readers = 1");
// let out = Some(r.read().await.channel.clone());
let guard = r.read().await;
dbg!("ISSUE> Never makes it after the read guard");
let channel = guard.channel.clone();
drop(guard);
let out = Some(channel);
// => 03.30 - This isn't reached because of the Deadlock // => 03.30 - This isn't reached because of the Deadlock
dbg!(">> Just after Potential Deadlock Lock"); dbg!(">> Just after Potential Deadlock Lock");

View file

@ -507,6 +507,7 @@ pub struct BotCommand {
impl BotCommand { impl BotCommand {
pub async fn execute(&self, params : ExecBodyParams) { pub async fn execute(&self, params : ExecBodyParams) {
// This is how BotCommand implements their Working exec_body
(*self.exec_body)(params).await; (*self.exec_body)(params).await;
} }
} }
@ -643,7 +644,7 @@ pub struct Routine {
pub name : String , pub name : String ,
pub module : BotModule , // from() can determine this if passed parents_params pub module : BotModule , // from() can determine this if passed parents_params
pub channel : Channel , // Requiring some channel context pub channel : Channel , // Requiring some channel context
exec_body: bot_actions::actions_util::ExecBody, exec_body: Arc<RwLock<bot_actions::actions_util::ExecBody>>,
pub parent_params : ExecBodyParams , pub parent_params : ExecBodyParams ,
pub join_handle : Option<Arc<RwLock<JoinHandle<RoutineAR>>>> , pub join_handle : Option<Arc<RwLock<JoinHandle<RoutineAR>>>> ,
start_time : Option<DateTime<Local>> , start_time : Option<DateTime<Local>> ,
@ -895,7 +896,7 @@ impl Routine {
module : BotModule , module : BotModule ,
channel : Channel, channel : Channel,
routine_attr : Vec<RoutineAttr> , routine_attr : Vec<RoutineAttr> ,
exec_body : bot_actions::actions_util::ExecBody , exec_body : Arc<RwLock<bot_actions::actions_util::ExecBody>> ,
parent_params : ExecBodyParams parent_params : ExecBodyParams
) -> Result< ) -> Result<
Arc<RwLock<Routine>>, Arc<RwLock<Routine>>,
@ -1285,17 +1286,43 @@ impl Routine {
parent_params parent_params
}; };
dbg!("Core > Guarding & Executing Child Execution Body"); dbg!("Core > Guarding and will Execute Child Execution Body");
dbg!(">> BotActionAR - RwLock from botmodules.rs::929:46 - current_readers = 0 "); dbg!(">> BotActionAR - RwLock from botmodules.rs::929:46 - current_readers = 0 ");
dbg!(">> RoutineAR - RwLock from botmodules.rs::1261:32 - current_readers = Not Listed"); dbg!(">> RoutineAR - RwLock from botmodules.rs::1261:32 - current_readers = Not Listed");
dbg!(">> BotInstanceAR - RwLock from botinstance.rs::150:28 - current_readers = 3 "); dbg!(">> BotInstanceAR - RwLock from botinstance.rs::150:28 - current_readers = 3 ");
// {
// // The below starts the Read Lock that conlicts
// let guard2 = self_ar.read().await;
// dbg!("Core > Guarded & Executing Child Execution Body");
// dbg!("!! [x] Document ");
// dbg!(">> BotActionAR - RwLock from botmodules.rs::929:46 - current_readers = 0 ");
// dbg!(">> RoutineAR - RwLock from botmodules.rs::1261:32 - current_readers = 1");
// dbg!(">> BotInstanceAR - RwLock from botinstance.rs::150:28 - current_readers = 2 ");
// // this way seems to be having issues for Routine > Loopbody
// // in particular, because by this point we have a ReadGuard on Routine
// // somehow the read guard is conflicting with a read guard in the underlying
// // fn?
// (guard2.exec_body)(parent_params).await;
// drop(guard2);
// }
{ {
let guard2 = self_ar.read().await; let guard2 = self_ar.read().await;
(guard2.exec_body)(parent_params).await; let exec_body_ar = guard2.exec_body.clone();
drop(guard2); drop(guard2);
let guard3 = exec_body_ar.read().await;
(guard3)(parent_params).await;
drop(guard3);
} }
// (self_ar.read().await.exec_body)( // (self_ar.read().await.exec_body)(
// parent_params // parent_params
// ).await; // ).await;

View file

@ -279,7 +279,7 @@ async fn countdown_chnl_v1(params : ExecBodyParams) {
module, module,
channel.unwrap(), channel.unwrap(),
routine_attr, routine_attr,
exec_body, Arc::new(RwLock::new(exec_body)),
params.clone() params.clone()
).await { ).await {
let newr_ar = newr.clone(); let newr_ar = newr.clone();
@ -475,7 +475,7 @@ async fn test3_body(params : ExecBodyParams) {
module, module,
channel.unwrap(), channel.unwrap(),
routine_attr, routine_attr,
exec_body, Arc::new(RwLock::new(exec_body)),
params.clone() params.clone()
).await; ).await;