Closed
Description
db__message_insert() in database.c calls util__decrement_send_quota with the wrong conditions.
Let's look at an example:
Conditions:
we have a valid socket, we have send msg quota left, we have no bytes quota left, QoS=1
db__ready_for_flight() returns false because no bytes quota left, hence the msg is queued.
Later we have the check (before decrementing the send msg quota)
if(dir == mosq_md_out && msg->qos > 0){
util__decrement_send_quota(context);
}
This will evaluate to true, but the msg was not ready for flight so why reduce the inflight quota?
Correct would be:
//state must be mosq_ms_publish_qos1 || mosq_ms_publish_qos2
if(dir == mosq_md_out && msg->qos > 0 && state != mosq_ms_queued){
util__decrement_send_quota(context);
}