From c3e25bda1a70a33e98d1ee426ec19d40dfca671b Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Wed, 8 Sep 2021 20:32:06 +0200 Subject: [PATCH] Run event / notification handlers in separate async tasks Prevents deadlocks when new handlers are registered from within an existing handler. --- matrix_sdk/src/client.rs | 2 +- matrix_sdk/src/event_handler.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/matrix_sdk/src/client.rs b/matrix_sdk/src/client.rs index 55c2d078..d65f7b1d 100644 --- a/matrix_sdk/src/client.rs +++ b/matrix_sdk/src/client.rs @@ -2123,7 +2123,7 @@ impl Client { }; for notification in room_notifications { - (handler)(notification.clone(), room.clone(), self.clone()).await; + tokio::spawn((handler)(notification.clone(), room.clone(), self.clone())); } } } diff --git a/matrix_sdk/src/event_handler.rs b/matrix_sdk/src/event_handler.rs index b569f59c..43df38c5 100644 --- a/matrix_sdk/src/event_handler.rs +++ b/matrix_sdk/src/event_handler.rs @@ -300,7 +300,7 @@ impl Client { room: room.clone(), raw: event.json(), }; - (handler)(data).await; + tokio::spawn((handler)(data)); } } }