From e4ddc31295b42ffc2fa8520c5d89db5b642093ce Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Sat, 31 May 2014 23:26:46 +0100 Subject: [PATCH] Fix for MQTT-3.8.4-3. --- src/subs.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/subs.c b/src/subs.c index 6194059f..9b5f0800 100644 --- a/src/subs.c +++ b/src/subs.c @@ -229,6 +229,19 @@ static int _sub_add(struct mosquitto_db *db, struct mosquitto *context, int qos, leaf = subhier->subs; last_leaf = NULL; while(leaf){ + if(leaf->context && leaf->context->id && !strcmp(leaf->context->id, context->id)){ + /* Client making a second subscription to same topic. Only + * need to update QoS. Return -1 to indicate this to the + * calling function. */ + leaf->qos = qos; + if(context->protocol == mosq_p_mqtt31){ + return -1; + }else{ + /* mqttv311 requires retained messages are resent on + * resubscribe. */ + return 0; + } + } last_leaf = leaf; leaf = leaf->next; }