ISSUE - potential lock issue
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful

This commit is contained in:
ModulatingForce 2024-03-29 09:03:16 -04:00
parent 66195138f8
commit b5e95668a5
2 changed files with 87 additions and 44 deletions

View file

@ -1104,7 +1104,9 @@ impl Routine {
// [x] execution body // [x] execution body
// trg_routine_ar.read().await.loopbody().await; // trg_routine_ar.read().await.loopbody().await;
trg_routine_ar.write().await.loopbody().await; {
trg_routine_ar.write().await.loopbody().await;
}
{ // [x] End of Loop iteration { // [x] End of Loop iteration

View file

@ -152,34 +152,44 @@ async fn countdown_chnl_v1(params : ExecBodyParams) {
async fn innertester(params : ExecBodyParams) { async fn innertester(params : ExecBodyParams) {
{
let curract_guard = params.curr_act.read().await;
let logmsg_botact = match *params.curr_act.read().await { // let logmsg_botact = match *params.curr_act.read().await {
BotAction::C(_) => "command",
BotAction::R(_) => "routine", let logmsg_botact = match *curract_guard {
BotAction::L(_) => "listener", BotAction::C(_) => "command",
} ; BotAction::R(_) => "routine",
BotAction::L(_) => "listener",
} ;
botlog::trace(
format!("Params > Curr_act type : {:?}", logmsg_botact).as_str(),
Some("Experiments003 > countdown_chnl()".to_string()),
Some(&params.msg),
);
Log::flush();
let bot = Arc::clone(&params.bot);
let botlock = bot.read().await;
if let BotAction::R(arr) = &*params.curr_act.read().await {
botlog::trace( botlog::trace(
"Before loading remaining iterations", format!("Params > Curr_act type : {:?}", logmsg_botact).as_str(),
Some("Experiments003 > countdown_chnl()".to_string()), Some("Experiments003 > countdown_chnl()".to_string()),
None, Some(&params.msg),
); );
Log::flush(); Log::flush();
}
{
let bot = Arc::clone(&params.bot);
let botlock = bot.read().await;
let curract_guard = params.curr_act.write().await;
// let routine_lock = arr.write().await;
if let BotAction::R(arr) = &*curract_guard {
// if let BotAction::R(arr) = &*params.curr_act.read().await {
botlog::trace(
"Before loading remaining iterations",
Some("Experiments003 > countdown_chnl()".to_string()),
None,
);
Log::flush();
// let iterleft = arr.read().await.remaining_iterations.unwrap_or(0); // let iterleft = arr.read().await.remaining_iterations.unwrap_or(0);
@ -197,10 +207,10 @@ async fn countdown_chnl_v1(params : ExecBodyParams) {
// } // }
{ {
let routine_lock = arr.write().await; let routine_lock = arr.write().await;
let a = routine_lock.remaining_iterations; let a = routine_lock.remaining_iterations;
println!("remaining iterations : {:?}", a); println!("remaining iterations : {:?}", a);
} }
botlog::trace( botlog::trace(
"after loading remaining iterations", "after loading remaining iterations",
@ -251,9 +261,12 @@ async fn countdown_chnl_v1(params : ExecBodyParams) {
// chosen_channel.0.clone(), // chosen_channel.0.clone(),
// outmsg, // outmsg,
// params.clone() // params.clone()
// ).await; // ).await;
} }
}
} }
@ -361,27 +374,55 @@ async fn test3_body(params : ExecBodyParams) {
async fn rtestbody(params : ExecBodyParams) { async fn rtestbody(params : ExecBodyParams) {
let logmsg_botact = match *params.curr_act.read().await { let guard = params.curr_act.read().await;
BotAction::C(_) => "command", {
BotAction::R(_) => "routine", let logmsg_botact = match *guard {
BotAction::L(_) => "listener", BotAction::C(_) => "command",
} ; BotAction::R(_) => "routine",
BotAction::L(_) => "listener",
} ;
botlog::trace( botlog::trace(
format!("Params > Curr_act type : {:?}", logmsg_botact).as_str(), format!("Params > Curr_act type : {:?}", logmsg_botact).as_str(),
Some("Experiments003 > test3 command body".to_string()), Some("Experiments003 > test3 command body".to_string()),
Some(&params.msg), Some(&params.msg),
); );
Log::flush(); Log::flush();
}
if let BotAction::R(arr) = &*params.curr_act.read().await {
for curriter in 0..5 { {
println!("tester - Routine - Completed Iterations : {}", let logmsg_botact = match *guard {
arr.read().await.complete_iterations); BotAction::C(_) => "command 2",
println!("tester - Custom Loop - Completed Iterations : {}", BotAction::R(_) => "routine 2",
curriter); BotAction::L(_) => "listener 2",
sleep(Duration::from_secs_f64(0.5)).await; } ;
botlog::trace(
format!("Params > Curr_act type : {:?}", logmsg_botact).as_str(),
Some("Experiments003 > test3 command body".to_string()),
Some(&params.msg),
);
Log::flush();
}
{
println!("Critical code area start"); // <= 03.29 - This is printed
if let BotAction::R(c) = &*guard {
println!("{:?}",c.read().await.channel);
} }
println!("Critical code area end"); // <= 03.29 - ISSUE This is NOT printed
// if let BotAction::R(arr) = &*params.curr_act.read().await {
// for curriter in 0..5 {
// println!("tester - Routine - Completed Iterations : {}",
// arr.read().await.complete_iterations);
// println!("tester - Custom Loop - Completed Iterations : {}",
// curriter);
// sleep(Duration::from_secs_f64(0.5)).await;
// }
// }
} }
} }