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,9 +152,13 @@ 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 {
let logmsg_botact = match *curract_guard {
BotAction::C(_) => "command", BotAction::C(_) => "command",
BotAction::R(_) => "routine", BotAction::R(_) => "routine",
BotAction::L(_) => "listener", BotAction::L(_) => "listener",
@ -167,12 +171,18 @@ async fn countdown_chnl_v1(params : ExecBodyParams) {
Some(&params.msg), Some(&params.msg),
); );
Log::flush(); Log::flush();
}
{
let bot = Arc::clone(&params.bot); let bot = Arc::clone(&params.bot);
let botlock = bot.read().await; let botlock = bot.read().await;
if let BotAction::R(arr) = &*params.curr_act.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( botlog::trace(
"Before loading remaining iterations", "Before 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,7 +374,9 @@ 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;
{
let logmsg_botact = match *guard {
BotAction::C(_) => "command", BotAction::C(_) => "command",
BotAction::R(_) => "routine", BotAction::R(_) => "routine",
BotAction::L(_) => "listener", BotAction::L(_) => "listener",
@ -373,15 +388,41 @@ async fn test3_body(params : ExecBodyParams) {
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 : {}",
arr.read().await.complete_iterations);
println!("tester - Custom Loop - Completed Iterations : {}",
curriter);
sleep(Duration::from_secs_f64(0.5)).await;
} }
{
let logmsg_botact = match *guard {
BotAction::C(_) => "command 2",
BotAction::R(_) => "routine 2",
BotAction::L(_) => "listener 2",
} ;
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;
// }
// }
} }
} }