Skip to content

Commit

Permalink
mosquitto_sub: fix MQTT v5 sub opts being set for v3 subs.
Browse files Browse the repository at this point in the history
Closes #1353. Thanks to Ben Barbour.
  • Loading branch information
ralight committed Jul 24, 2019
1 parent 2b2afc9 commit 0ba8f43
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ChangeLog.txt
Expand Up @@ -7,6 +7,10 @@ Broker:
- Windows: Allow other applications access to the log file when running.
Closes #515.

Clients:
- mosquitto_sub: fix MQTT v5 subscription options being incorrectly set for
MQTT v3 subscriptions. Closes #1353.


1.6.3 - 20190618
================
Expand Down
9 changes: 8 additions & 1 deletion client/sub_client.c
Expand Up @@ -112,13 +112,20 @@ void my_message_callback(struct mosquitto *mosq, void *obj, const struct mosquit
void my_connect_callback(struct mosquitto *mosq, void *obj, int result, int flags, const mosquitto_property *properties)
{
int i;
int sub_opts;

UNUSED(obj);
UNUSED(flags);
UNUSED(properties);

if(cfg.protocol_version == MQTT_PROTOCOL_V5){
sub_opts = cfg.sub_opts;
}else{
sub_opts = 0;
}

if(!result){
mosquitto_subscribe_multiple(mosq, NULL, cfg.topic_count, cfg.topics, cfg.qos, cfg.sub_opts, cfg.subscribe_props);
mosquitto_subscribe_multiple(mosq, NULL, cfg.topic_count, cfg.topics, cfg.qos, sub_opts, cfg.subscribe_props);

for(i=0; i<cfg.unsub_topic_count; i++){
mosquitto_unsubscribe_v5(mosq, NULL, cfg.unsub_topics[i], cfg.unsubscribe_props);
Expand Down

0 comments on commit 0ba8f43

Please sign in to comment.