mqtt: Break out of receive loop on disconnect
Apparently, the `AsyncReceiver` stream produces nested `Option` objects. The outer is `None` if "the stream is exhausted," which is somehow different than the connection being closed; the inner `Option` is `None` in that case. We were originally ignoring the inner `None`, but just causes the async task to go into a busy loop when connection is closed. We need to break out of the loop there instead.dev/ci
parent
94a47d863c
commit
e92d8c9cef
|
@ -103,7 +103,7 @@ impl<'a> MqttClient<'a> {
|
||||||
client.disconnect(None);
|
client.disconnect(None);
|
||||||
});
|
});
|
||||||
while let Some(msg) = self.stream.next().await {
|
while let Some(msg) = self.stream.next().await {
|
||||||
let Some(msg) = msg else {continue};
|
let Some(msg) = msg else {break};
|
||||||
trace!("Received message: {:?}", msg);
|
trace!("Received message: {:?}", msg);
|
||||||
for m in self.topics.matches(msg.topic()) {
|
for m in self.topics.matches(msg.topic()) {
|
||||||
match m.1 {
|
match m.1 {
|
||||||
|
|
Loading…
Reference in New Issue