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

Mqtt311 decoder #311

Merged
merged 10 commits into from
Jul 26, 2023
Merged

Mqtt311 decoder #311

merged 10 commits into from
Jul 26, 2023

Conversation

bretambrose
Copy link
Contributor

@bretambrose bretambrose commented Jul 24, 2023

  • Fix a framing bug that led to dead/broken connections
  • Refactor the framing logic used by the mqtt311 implementation to use an encapsulated, testable subsystem (aws_mqtt311_decoder).

While we could have fixed the original bug without doing such a heavyweight refactor, testing complex, brittle logic embedded in the channel handler's vtable implementation is a lousy approach. Rather than graft more hacks and more complexity into the client impl, we add a new subsystem with a testable API.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@codecov-commenter
Copy link

codecov-commenter commented Jul 24, 2023

Codecov Report

Patch coverage: 85.33% and project coverage change: +0.59% 🎉

Comparison is base (7aaae0c) 81.10% compared to head (d89aef3) 81.69%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #311      +/-   ##
==========================================
+ Coverage   81.10%   81.69%   +0.59%     
==========================================
  Files          18       19       +1     
  Lines        7842     7923      +81     
==========================================
+ Hits         6360     6473     +113     
+ Misses       1482     1450      -32     
Files Changed Coverage Δ
source/client_channel_handler.c 73.54% <64.40%> (+4.98%) ⬆️
source/mqtt311_decoder.c 98.80% <98.80%> (ø)
source/client.c 69.29% <100.00%> (-0.11%) ⬇️
source/fixed_header.c 87.93% <100.00%> (+12.06%) ⬆️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@graebm graebm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (handler != NULL) {
return handler(packet_cursor, decoder->config.handler_user_data);
} else {
return aws_raise_error(AWS_ERROR_MQTT_PROTOCOL_ERROR);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trivial: just FYI, if you wanted to logging from within this file but didn't know what ID to use...

I usually pass a void *logging_id in the decoder_options, so the decoder can log with the same ID as the the system that owns it

source/mqtt311_decoder.c Show resolved Hide resolved
source/mqtt311_decoder.c Show resolved Hide resolved
source/mqtt311_decoder.c Show resolved Hide resolved
source/mqtt311_decoder.c Outdated Show resolved Hide resolved
source/mqtt311_decoder.c Show resolved Hide resolved
source/mqtt311_decoder.c Outdated Show resolved Hide resolved
source/mqtt311_decoder.c Outdated Show resolved Hide resolved
@bretambrose
Copy link
Contributor Author

source/client_channel_handler.c Show resolved Hide resolved
source/client_channel_handler.c Outdated Show resolved Hide resolved
source/client_channel_handler.c Show resolved Hide resolved
source/client_channel_handler.c Show resolved Hide resolved
source/client_channel_handler.c Outdated Show resolved Hide resolved
@bretambrose bretambrose merged commit d5c268f into main Jul 26, 2023
@bretambrose bretambrose deleted the Mqtt311Decoder branch July 26, 2023 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants