Browse Source

Fix potential of deadlock with MQTT

master
Alex Mikhalev 4 years ago
parent
commit
244eea66eb
  1. 11
      src/mqtt_interface.rs

11
src/mqtt_interface.rs

@ -73,7 +73,16 @@ async fn event_loop_task( @@ -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?;
}
_ => {}
}

Loading…
Cancel
Save