writelock_issue #45

Merged
modulatingforce merged 4 commits from issue-chat-say-id-write-lock into parent-botaction-to-child-fn 2024-03-24 23:44:25 -04:00
Showing only changes of commit ab5624c6fa - Show all commits

View file

@ -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(&params.bot);
let params_clone = params.clone();
let botclone = Arc::clone(&params_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(&params.msg),
// );
// Log::flush();
botlog::trace(
"ACQUIRING WRITE LOCK : ID",
"ACQUIRING READ LOCK : ID",
Some("Chat > send_botmsg".to_string()),
Some(&params.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(&params.msg),
);
Log::flush();
// botlog::trace(
// "ACQUIRED WRITE LOCK : ID",
// Some("Chat > send_botmsg".to_string()),
// Some(&params.msg),
// );
// Log::flush();
botlog::trace(
"ACQUIRED READ LOCK : ID",
Some("Chat > send_botmsg".to_string()),
Some(&params.msg),
);
Log::flush();
self.send_botmsg(BotMsgType::SayInReplyTo(msg, outmsg) , params).await;