Skip to content

network: address socket interface pointer instead of name#12550

Merged
mattklein123 merged 5 commits intoenvoyproxy:masterfrom
florincoras:addr_sock
Aug 12, 2020
Merged

network: address socket interface pointer instead of name#12550
mattklein123 merged 5 commits intoenvoyproxy:masterfrom
florincoras:addr_sock

Conversation

@florincoras
Copy link
Copy Markdown
Member

Signed-off-by: Florin Coras fcoras@cisco.com

Risk Level: Low
Testing: unit tests
Docs Changes: n/a
Release Notes: n/a

Signed-off-by: Florin Coras <fcoras@cisco.com>
antoniovicente
antoniovicente previously approved these changes Aug 7, 2020
Copy link
Copy Markdown
Contributor

@antoniovicente antoniovicente left a comment

Choose a reason for hiding this comment

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

Looks great.

@dio dio assigned lizan Aug 7, 2020
Signed-off-by: Florin Coras <fcoras@cisco.com>
Copy link
Copy Markdown
Member

@lizan lizan left a comment

Choose a reason for hiding this comment

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

Thanks, this looks much better. Just some style nits.


} // namespace

static inline const SocketInterface* sockInterfaceOrDefault(const SocketInterface* sock_interface) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

style nit: put this in unnamed namespace above, remove static, doesn't have to be inline?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's a C reflex of mine that I use instead of macros. Goal would be to convince the compiler to avoid extra function calls when not needed. But obviously, no strong opinion here ...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

C++ inline isn't guaranteed to be inlined, all are decided by compiler, it's more of working around one-definition rule.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Understood!

* @return SocketInterface to be used with the address
*/
virtual const std::string& socketInterface() const PURE;
virtual const Network::SocketInterface* socketInterface() const PURE;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

let's return reference, it's no longer nullable.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We'll have to keep the const because of how we pass the SocketInterface pointer to the Address. Is that okay or were you thinking about something more complex?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ah of couse, const wherever possible :)

Signed-off-by: Florin Coras <fcoras@cisco.com>
Signed-off-by: Florin Coras <fcoras@cisco.com>

std::string friendly_name_;
std::string socket_interface_;
const SocketInterface* socket_interface_;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This can be const ref as well

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done!

Signed-off-by: Florin Coras <fcoras@cisco.com>
Copy link
Copy Markdown
Member

@lizan lizan left a comment

Choose a reason for hiding this comment

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

Thanks!

@florincoras
Copy link
Copy Markdown
Member Author

Thanks!

Thank you for the review!

@mattklein123 mattklein123 merged commit 18a5124 into envoyproxy:master Aug 12, 2020
@florincoras florincoras deleted the addr_sock branch August 28, 2020 20:02
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.

4 participants