Skip to content

Do not delete message before delivering packet #1081

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

Merged
merged 4 commits into from
May 7, 2025

Conversation

kickster97
Copy link
Member

WHAT is this pull request doing?

The build_packet method constructs an MQTT::Publish packet using the message data stored in env.message.
If the message has already been deleted (via delete_message(sp)), the env.message reference becomes invalid, leading to a segmentation fault when accessed.

This PR also fixes a bug where the @consumers.empty? never got triggered because the deliver_loop didn't yield in time for the read_loop to take over and set the client=nil, so the deliver_loop would continue to loop errors.
Now we set client=nil when the deliver_loop experiences an error, so the consumers.empty? channel triggers and the loop waits for a new client connection.

HOW can this pull request be tested?

run lavinmqperf mqtt throughput via the mqtt-perf branch and make sure there are no segment faults.

@kickster97 kickster97 requested a review from a team as a code owner April 29, 2025 09:10
@kickster97 kickster97 changed the title don't delete message before delivering packet Do not delete message before delivering packet Apr 29, 2025
@kickster97 kickster97 force-pushed the deliver_packet_before_delete branch from c89633e to 81fbdbb Compare May 6, 2025 08:46
@kickster97 kickster97 requested a review from spuun May 6, 2025 09:30
@kickster97 kickster97 requested a review from carlhoerberg May 6, 2025 12:38
carlhoerberg

This comment was marked as outdated.

Co-authored-by: Carl Hörberg <carl@84codes.com>
@kickster97 kickster97 added the bug label May 7, 2025
@kickster97 kickster97 merged commit 1ac1c52 into main May 7, 2025
15 of 17 checks passed
@kickster97 kickster97 deleted the deliver_packet_before_delete branch May 7, 2025 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants