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

Updating parsing to avoid copying #95

Merged
merged 3 commits into from
Aug 23, 2022
Merged

Conversation

ryan-summers
Copy link
Member

This PR refactors the packet reception mechanism in Minimq to receive directly from the network stack into the PacketReader. The PacketParser has been broken off the PacketReader in anticipation of deserialization refactoring in the future.

This avoids one copy of the MQTT packet from the receive buffer into the packet reader.

Additionally, this PR updates it so that only a single MQTT packet is read from the network per poll() execution at most, which paves the way for fixing #80.

0x30, // Publish, no QoS
0x04, // Remaining length
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm somewhat unsure why this was passing in the past. It looks completely wrong to me - there's obviously 5 bytes following the packet.

Copy link
Member

@jordens jordens left a comment

Choose a reason for hiding this comment

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

Very nice cleanup.

src/de/deserialize.rs Outdated Show resolved Hide resolved
src/de/packet_parser.rs Show resolved Hide resolved
@ryan-summers ryan-summers merged commit 2e8dad5 into master Aug 23, 2022
@ryan-summers ryan-summers deleted the feature/parsing-optimization branch August 23, 2022 12:23
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.

2 participants