From 56d0b950ac0dde4abd3707ec73688848b9c47a13 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Wed, 5 Feb 2020 15:19:55 +0000 Subject: [PATCH] Fix `--remove-retained` not obeying the `-T` option. This means `--remove-retained -t bbc/# -T bbc/one/#` would remove all retained messages in `bbc/#`, instead of leaving all of the topics in `bbc/one/#`. Closes #1585. Thanks to Simon Moser. --- ChangeLog.txt | 6 +++++- client/sub_client.c | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 412cfcef..9ea60815 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -14,10 +14,14 @@ Broker: - Print OpenSSL errors in more situations, like when loading certificates fails. Closes #1552. -Library: +Client library: - Set minimum keepalive argument to `mosquitto_connect*()` to be 5 seconds. Closes #1550. +Clients: +- Fix `--remove-retained` not obeying the `-T` option for filtering out + topics. Closes #1585. + 1.6.8 - 20191128 ================ diff --git a/client/sub_client.c b/client/sub_client.c index 8894ca05..ca471a23 100644 --- a/client/sub_client.c +++ b/client/sub_client.c @@ -76,10 +76,6 @@ void my_message_callback(struct mosquitto *mosq, void *obj, const struct mosquit if(process_messages == false) return; - if(cfg.remove_retained && message->retain){ - mosquitto_publish(mosq, &last_mid, message->topic, 0, NULL, 1, true); - } - if(cfg.retained_only && !message->retain && process_messages){ process_messages = false; if(last_mid == 0){ @@ -96,6 +92,10 @@ void my_message_callback(struct mosquitto *mosq, void *obj, const struct mosquit } } + if(cfg.remove_retained && message->retain){ + mosquitto_publish(mosq, &last_mid, message->topic, 0, NULL, 1, true); + } + print_message(&cfg, message); if(cfg.msg_count>0){