Commits

Roger Light committed 5ea2019

Ensure that QoS 2 queued messages are sent out in a timely manner. Thanks to Dirk O. Kaar.

Comments (0)

Files changed (2)

 Broker:
 - Fix max_inflight_messages and max_queued_messages not being applied.
 - Fix documentation error in mosquitto.conf.
+- Ensure that QoS 2 queued messages are sent out in a timely manner.
 
 Client:
 - Fix "mosquitto_pub -l -q 2" disconnecting before all messages were
 	int qos;
 	uint32_t payloadlen;
 	const void *payload;
+	int msg_count = 0;
 
 	if(!context || context->sock == -1
 			|| (context->state == mosq_cs_connected && !context->id)){
 
 	tail = context->msgs;
 	while(tail){
+		if(tail->direction == mosq_md_in){
+			msg_count++;
+		}
 		if(tail->state != ms_queued){
 			mid = tail->mid;
 			retries = tail->dup;
 					break;
 			}
 		}else{
-			last = tail;
-			tail = tail->next;
+			/* state == ms_queued */
+			if(tail->direction == mosq_md_in && (max_inflight == 0 || msg_count < max_inflight)){
+				if(tail->qos == 2){
+					tail->state = ms_send_pubrec;
+				}
+			}else{
+				last = tail;
+				tail = tail->next;
+			}
 		}
 	}