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

Convert mdns Builder classes to use PacketBufferHandle #4094

Merged
merged 10 commits into from
Jan 8, 2021

Conversation

kpschoedel
Copy link
Contributor

Problem

Code should use PacketBufferHandle rather than PacketBuffer
directly.

Summary of Changes

Convert mdns::Minimal::QueryBuilder and mdns::Minimal::ResponseBuilder
to take and hold PacketBufferHandle.

Part of issue #2707 - Figure out a way to express PacketBuffer ownership in the type system

#### Problem

Code should use `PacketBufferHandle` rather than `PacketBuffer`
directly.

#### Summary of Changes

Convert mdns::Minimal::QueryBuilder and mdns::Minimal::ResponseBuilder
to take and hold PacketBufferHandle.

Part of issue project-chip#2707 - Figure out a way to express PacketBuffer ownership in the type system
@@ -213,7 +213,7 @@ void BroadcastPacket(mdns::Minimal::ServerBase * server)
QuerySplitter query;
query.Split(gOptions.query);

mdns::Minimal::QueryBuilder builder(buffer.Get_ForNow());
mdns::Minimal::QueryBuilder builder(buffer.Retain());
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm. It seems like we could make the builder take a const ref to PacketBufferHandle (and have its member be a const ref) and avoid the extra refcounting And here we could scope it so it goes out of scope before we do the BroadcastSend call...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, yes. I probably had TLV's chaining in mind when I converted this one. Fixed.

@bzbarsky-apple
Copy link
Contributor

@kpschoedel Merge conflicts?

@andy31415
Copy link
Contributor

also #4102 has some conversions to PacketBufferHandle (not sure if the same, but if we could make them similar it may be easier to merge)

@kpschoedel
Copy link
Contributor Author

also #4102 has some conversions to PacketBufferHandle (not sure if the same, but if we could make them similar it may be easier to merge)

Yes, I think #4102 makes the ResponseBuilder part of this PR redundant, so I'll just remove it.

@kpschoedel
Copy link
Contributor Author

Converted to draft as this now depends on #4102

Removed ResponseBuilder changes (redundant after #4102) and converted QueryBuilder to use the same interface pattern as ResponseBuilder there.

@kpschoedel kpschoedel marked this pull request as ready for review December 8, 2020 15:00
@andy31415 andy31415 merged commit f77bebf into project-chip:master Jan 8, 2021
@kpschoedel kpschoedel deleted the x2707-10-mdns-builder branch January 8, 2021 17:20
kpschoedel added a commit to kpschoedel/connectedhomeip that referenced this pull request Jan 8, 2021
…4094)

* Convert mdns Builder classes to use PacketBufferHandle

#### Problem

Code should use `PacketBufferHandle` rather than `PacketBuffer`
directly.

#### Summary of Changes

Convert mdns::Minimal::QueryBuilder and mdns::Minimal::ResponseBuilder
to take and hold PacketBufferHandle.

Part of issue project-chip#2707 - Figure out a way to express PacketBuffer ownership in the type system

* Review: make QueryBuilder take const&

* WIP

* Revise to match ResponseBuilder in project-chip#4102

* Restyled by clang-format

* remove PacketReporter.cpp change

Co-authored-by: Restyled.io <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants