Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

db__message_insert decrements inflight quota although message was queued #2306

Closed
canique opened this issue Sep 8, 2021 · 1 comment
Closed
Labels
Component: mosquitto-broker Status: Completed Nothing further to be done with this issue, it can be closed by the requestor or committer. Type: Bug
Milestone

Comments

@canique
Copy link

canique commented Sep 8, 2021

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);
}
@canique canique changed the title db__message_insert decrements send quota although message was queued db__message_insert decrements inflight quota although message was queued Sep 8, 2021
canique added a commit to canique/mosquitto that referenced this issue Sep 8, 2021
@ralight
Copy link
Contributor

ralight commented Sep 22, 2021

Thanks, I agree with your assessment. Whilst developing a test for it I uncovered a few other inconsistencies which I've fixed as well. Please do take a look at the fixes branch.

ralight added a commit that referenced this issue Sep 22, 2021
@ralight ralight added Component: mosquitto-broker Status: Completed Nothing further to be done with this issue, it can be closed by the requestor or committer. Type: Bug labels Sep 22, 2021
@ralight ralight added this to the 2.0.13 milestone Sep 22, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Component: mosquitto-broker Status: Completed Nothing further to be done with this issue, it can be closed by the requestor or committer. Type: Bug
Projects
None yet
Development

No branches or pull requests

2 participants