From ab5624c6fa8fe2e6bc4778bd34ac7cbe17f68d75 Mon Sep 17 00:00:00 2001 From: ModulatingForce <116608425+modulatingforce@users.noreply.github.com> Date: Sun, 24 Mar 2024 22:55:38 -0400 Subject: [PATCH] (init) solution --- src/core/chat.rs | 47 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/src/core/chat.rs b/src/core/chat.rs index 2df41db..d596a68 100644 --- a/src/core/chat.rs +++ b/src/core/chat.rs @@ -464,29 +464,58 @@ impl Chat { // pub async fn say_in_reply_to(&self, msg: &PrivmsgMessage, outmsg: String) { - #[async_recursion] + // #[async_recursion] pub async fn say_in_reply_to(&self, msg: &PrivmsgMessage, outmsg: String , params : ExecBodyParams) { - let botclone = Arc::clone(¶ms.bot); + let params_clone = params.clone(); + + let botclone = Arc::clone(¶ms_clone.bot); let botlock = botclone.read().await; let id = botlock.get_identity(); + let id = Arc::clone(&id); + + // botlog::trace( + // "ACQUIRING WRITE LOCK : ID", + // Some("Chat > send_botmsg".to_string()), + // Some(¶ms.msg), + // ); + // Log::flush(); botlog::trace( - "ACQUIRING WRITE LOCK : ID", + "ACQUIRING READ LOCK : ID", Some("Chat > send_botmsg".to_string()), Some(¶ms.msg), ); + Log::flush(); - - { - let mut idlock = id.write().await; // <-- [ ] 03.24 - This is definitely locking it - } - + + // let idlock = id.write().await; // <-- [ ] 03.24 - This is definitely locking it + let idlock = id.read().await; // <-- [ ] 03.24 - seems to work + let a = idlock.getspecialuserroles(params.get_sender(), Some(Channel(msg.channel_login.clone()))).await; botlog::trace( - "ACQUIRED WRITE LOCK : ID", + format!("GETSPECIALUSERROLES RESULT : {:?}",a).as_str(), Some("Chat > send_botmsg".to_string()), Some(¶ms.msg), ); + Log::flush(); + + + + // botlog::trace( + // "ACQUIRED WRITE LOCK : ID", + // Some("Chat > send_botmsg".to_string()), + // Some(¶ms.msg), + // ); + // Log::flush(); + + + + botlog::trace( + "ACQUIRED READ LOCK : ID", + Some("Chat > send_botmsg".to_string()), + Some(¶ms.msg), + ); + Log::flush(); self.send_botmsg(BotMsgType::SayInReplyTo(msg, outmsg) , params).await;