summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDidier Wenzek <didier.wenzek@free.fr>2022-02-07 11:45:57 +0000
committerDidier Wenzek <didier.wenzek@free.fr>2022-02-07 11:45:57 +0000
commit5cb84b411a75a37ef7487e84273b370c140ec90b (patch)
tree0a35d7bf1355b540045d87c483d6736023bf0ae2
parentc15cfc4bee97473411ed173903f808c1132b8d8c (diff)
Remove useless unsubscribe calls on clear_session
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
-rw-r--r--crates/common/mqtt_channel/src/session.rs10
-rw-r--r--crates/common/mqtt_channel/src/tests.rs11
2 files changed, 9 insertions, 12 deletions
diff --git a/crates/common/mqtt_channel/src/session.rs b/crates/common/mqtt_channel/src/session.rs
index c41acb52..334c48c6 100644
--- a/crates/common/mqtt_channel/src/session.rs
+++ b/crates/common/mqtt_channel/src/session.rs
@@ -67,16 +67,6 @@ pub async fn clear_session(config: &Config) -> Result<(), MqttError> {
loop {
match event_loop.poll().await {
Ok(Event::Incoming(Packet::ConnAck(_))) => {
- let subscriptions = config.subscriptions.filters();
- if subscriptions.is_empty() {
- break;
- }
- for s in subscriptions.iter() {
- mqtt_client.unsubscribe(&s.path).await?;
- }
- }
-
- Ok(Event::Incoming(Packet::UnsubAck(_))) => {
break;
}
diff --git a/crates/common/mqtt_channel/src/tests.rs b/crates/common/mqtt_channel/src/tests.rs
index 187a62c2..ff1ebaab 100644
--- a/crates/common/mqtt_channel/src/tests.rs
+++ b/crates/common/mqtt_channel/src/tests.rs
@@ -403,8 +403,15 @@ mod tests {
.publish(topic, "A 2nd msg published before clean")
.await?;
- // If we clean the session
- clear_session(&mqtt_config).await?;
+ // Then we clean the session
+ {
+ // One just needs a config with the same session name.
+ // Subscriptions can be given - but this not required: any previous subscriptions will be cleared.
+ let mqtt_config = Config::default()
+ .with_port(broker.port)
+ .with_session_name(session_name);
+ clear_session(&mqtt_config).await?;
+ }
// And publish more messages
broker