From 244eea66ebb4bedc368582f002a7f0e2ab29cf5c Mon Sep 17 00:00:00 2001 From: Alex Mikhalev Date: Sun, 27 Sep 2020 21:51:36 -0600 Subject: [PATCH] Fix potential of deadlock with MQTT --- src/mqtt_interface.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/mqtt_interface.rs b/src/mqtt_interface.rs index 036dca1..aa41672 100644 --- a/src/mqtt_interface.rs +++ b/src/mqtt_interface.rs @@ -73,7 +73,16 @@ async fn event_loop_task( match incoming { rumqttc::Packet::ConnAck(_) => { info!("MQTT connected"); - interface.publish_connected(true).await?; + { + // HACK: this really should just be await + // but that can sometimes deadlock if the publish channel is full + let mut interface = interface.clone(); + let fut = async move { + interface.publish_connected(true).await + }; + tokio::spawn(fut); + } + //.await?; } _ => {} }