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

Simplify handling of sockaddr information lookup #38

Merged
merged 8 commits into from
Apr 28, 2023

Conversation

wence-
Copy link
Contributor

@wence- wence- commented Apr 27, 2023

Migrate away from using gethostbyname (deprecated) to getaddrinfo. As a consequence, we can refactor some memory management and handle allocation lifetime with a unique_ptr.

Although this doesn't introduce a class for managing sockaddr objects, it does make the lifetime management transparent enough that this closes #8.

wence- added 5 commits April 27, 2023 12:24
With a custom deleter, we must take care to also delete the pointer
managed by the unique_ptr.
Rather than gethostbyname and then manually constructing a struct
sockaddr_in, make the lookup IPv6-agnostic by using getaddrinfo
directly.
Rather than heap-allocating the endpoint parameters, as well as the
addrinfo, stack allocate the endpoint parameters and use a unique_ptr
managed heap allocation for addrinfo.

This is safe because endpoint and listener creation copies the
addrinfo data upon initialisation.
Now that this just returns an addrinfo struct, the previous name was
misleading.
@wence- wence- requested a review from a team as a code owner April 27, 2023 15:36
Copy link
Member

@pentschev pentschev left a comment

Choose a reason for hiding this comment

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

Thanks @wence- , this looks great! I left a few suggestions on style, and one typo fix (which is not even modified in this PR but I catched and suggested it anyway).

cpp/include/ucxx/utils/sockaddr.h Outdated Show resolved Hide resolved
cpp/src/endpoint.cpp Outdated Show resolved Hide resolved
cpp/src/endpoint.cpp Outdated Show resolved Hide resolved
cpp/src/endpoint.cpp Outdated Show resolved Hide resolved
@wence-
Copy link
Contributor Author

wence- commented Apr 28, 2023

Thanks, done!

Copy link
Member

@pentschev pentschev left a comment

Choose a reason for hiding this comment

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

Thanks Lawrence!

@wence-
Copy link
Contributor Author

wence- commented Apr 28, 2023

I just squashed the remaining few places where param structs were separated from initialisation.

@pentschev
Copy link
Member

/merge

@rapids-bot rapids-bot bot merged commit 91ddfb9 into rapidsai:branch-0.32 Apr 28, 2023
@wence- wence- deleted the wence/fea/sock-addr branch April 28, 2023 19:21
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.

Create a class to handle ucs_sock_addr_t
2 participants