From 142d07f45a941a5c6494bb2a1130df2b4f087857 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Wed, 29 May 2019 16:19:18 +0100 Subject: [PATCH] Fix MQTT v5 overlapping subscription behaviour. Clients now receive message from all matching subscriptions rather than the first one encountered, which ensures the maximum QoS requirement is met. --- ChangeLog.txt | 3 +++ src/database.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 509dbaf8..a98221a3 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -25,6 +25,9 @@ Broker: - Fix incorrect shared subscription topic '$shared'. - Fix zero length client ids being rejected for MQTT v5 clients with clean start set to true. +- Fix MQTT v5 overlapping subscription behaviour. Clients now receive message + from all matching subscriptions rather than the first one encountered, which + ensures the maximum QoS requirement is met. Client library: - Fix typo causing build error on Windows when building without TLS support. diff --git a/src/database.c b/src/database.c index 4d70b73d..482e210f 100644 --- a/src/database.c +++ b/src/database.c @@ -364,7 +364,8 @@ int db__message_insert(struct mosquitto_db *db, struct mosquitto *context, uint1 * multiple times for overlapping subscriptions, although this is only the * case for SUBSCRIPTION with multiple subs in so is a minor concern. */ - if(db->config->allow_duplicate_messages == false + if(context->protocol != mosq_p_mqtt5 + && db->config->allow_duplicate_messages == false && dir == mosq_md_out && retain == false && stored->dest_ids){ for(i=0; idest_id_count; i++){