Commits

Roger Light committed 3528ee4

Local bridges with clean_session==false now remove unused subscriptions on
broker restart.

Comments (0)

Files changed (2)

 - Fix documentation error in mosquitto.conf.
 - Ensure that QoS 2 queued messages are sent out in a timely manner.
 - Local bridges now act on clean_session correctly.
+- Local bridges with clean_session==false now remove unused subscriptions on
+  broker restart.
 
 Library:
 - Don't produce return error from mosquitto_loop() if a system call is
 	mqtt3_db_message_reconnect_reset(context);
 
 	if(context->clean_session){
-		mqtt3_subs_clean_session(db, context, &db->subs);
 		mqtt3_db_messages_delete(context);
 	}
 
+	/* Delete all local subscriptions even for clean_session==false. We don't
+	 * remove any messages and the next loop carries out the resubscription
+	 * anyway. This means any unwanted subs will be removed.
+	 */
+	mqtt3_subs_clean_session(db, context, &db->subs);
+
 	for(i=0; i<context->bridge->topic_count; i++){
 		if(context->bridge->topics[i].direction == bd_out || context->bridge->topics[i].direction == bd_both){
 			_mosquitto_log_printf(NULL, MOSQ_LOG_DEBUG, "Bridge %s doing local SUBSCRIBE on topic %s", context->id, context->bridge->topics[i].local_topic);
 			if(mqtt3_sub_add(db, context, context->bridge->topics[i].local_topic, context->bridge->topics[i].qos, &db->subs)) return 1;
-		}else{
-			/* direction = inwards only. This means we should not be subscribed
-			 * to the topic. It is possible that we used to be subscribed to
-			 * this topic so unsubscribe. */
-			mqtt3_sub_remove(db, context, context->bridge->topics[i].local_topic, &db->subs);
 		}
 	}