Commit 4bc43adf13

4bc43adf13986a03494a50e91e71fe602c28dbee

parent: da23d0f62d

Unsigned

Damir Jelić <poljar@termina.org.uk> · 2021-02-02 17:48 UTC

room: Don't hold on to connection borrows across await points

Layout: unified · split

src/room/mod.rs +6 −2
@@ -619,7 +619,9 @@ impl MatrixRoom {
619 pub async fn send_message(&self, content: MessageEventContent) { 619 pub async fn send_message(&self, content: MessageEventContent) {
620 let uuid = Uuid::new_v4(); 620 let uuid = Uuid::new_v4();
621 621
622 if let Some(c) = &*self.connection.borrow() { 622 let connection = self.connection.borrow().clone();
623
624 if let Some(c) = connection {
623 self.queue_outgoing_message(uuid, &content).await; 625 self.queue_outgoing_message(uuid, &content).await;
624 match c 626 match c
625 .send_message( 627 .send_message(
@@ -686,7 +688,9 @@ impl MatrixRoom {
686 } 688 }
687 }; 689 };
688 690
689 if let Some(connection) = &*connection.borrow() { 691 let connection = connection.borrow().clone();
692
693 if let Some(connection) = connection {
690 let response = 694 let response =
691 connection.send_typing_notice(&*room_id, typing).await; 695 connection.send_typing_notice(&*room_id, typing).await;
692 696