fix: deadlock while leaving room

This commit is contained in:
Ahmet Kaan Gümüş 2025-05-24 01:54:09 +03:00
parent 7bbae2b0be
commit b0bb6c6a90
4 changed files with 15 additions and 13 deletions

View file

@ -26,21 +26,17 @@ struct Signal {
impl Signal {
fn reset_connection(&self) -> Result<(), Error> {
if let Some(connection_signal) = self.connection_stop_sender.read().unwrap().as_ref() {
if !connection_signal.is_closed() {
let mut connection_stop_sender = self.connection_stop_sender.write().unwrap();
connection_stop_sender
.take()
.expect("Never")
.send(true)
.unwrap();
let connection_stop_sender = self.connection_stop_sender.write().unwrap().take();
match connection_stop_sender {
Some(connection_stop_sender) => {
connection_stop_sender.send(true).unwrap();
*connection_stop_sender = None;
drop(connection_stop_sender);
return Ok(());
Ok(())
}
None => Err(Error::NotSupposeTo(
"Connection Stop Sender is None".to_string(),
))?,
}
Err(Error::Signal("Reset".to_string()))
}
}

View file

@ -79,8 +79,12 @@ pub async fn disconnect_watcher(
);
}
println!("Going to Disconnect");
connect_return.send_audio_task.abort();
connect_return.receive_audio_task.abort();
println!("Disconnected");
}
async fn send_audio_data(

View file

@ -90,7 +90,7 @@ pub async fn play(
},
}
} else {
*sample = 0.0;
*sample = 0.0
}
}
};