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

[IP6NS Grant] Improve hostname resolution #1166

Merged
merged 7 commits into from
Oct 7, 2019

Conversation

Kaiepi
Copy link
Contributor

@Kaiepi Kaiepi commented Aug 27, 2019

This makes a few different changes to hostname resolution. First, it makes it so when resolving hostnames on systems where no IPv6 addresses actually exist on the interface used, an IPv6 address will never be returned by MVM_io_resolve_host_name, and likewise for IPv4. Second, rather than MVM_io_resolve_host_name only returning the first address returned by getaddrinfo, it returns all of them instead, and functions using its return value now attempt to use all of them before they actually throw. Finally, MVM_io_resolve_host_name now takes parameters for socket types, protocols, and passivity, which makes it so it doesn't return addresses that can't actually be used when those are specified.

This is currently broken, as the uv_udp_t handle bound when MVM_io_async_socket_udp gets called is zeroed out in write_setup. Interestingly, if I don't set handle->data to NULL, the SocketSetupInfo struct there ends up being the only struct member not to be zeroed out. Maybe the GC's involved getting involved here somehow?

Fixes rakudo/rakudo#3007
Fixes rakudo/rakudo#2162

src/io/asyncsocket.c Outdated Show resolved Hide resolved
@Kaiepi Kaiepi changed the title [WIP] [IP6NS Grant] Improve hostname resolution [IP6NS Grant] Improve hostname resolution Aug 30, 2019
@Kaiepi
Copy link
Contributor Author

Kaiepi commented Aug 30, 2019

OK, this should be ready for review now

@Kaiepi Kaiepi force-pushed the ipv6-unsupported branch 2 times, most recently from 4ab431e to 3b1cf34 Compare September 2, 2019 17:35
Copy link
Contributor

@AlexDaniel AlexDaniel left a comment

Choose a reason for hiding this comment

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

Waiting for a fix/confirmation of a leak, please don't merge before that is resolved.

https://colabti.org/irclogger/irclogger_log/perl6-dev?date=2019-09-06#l1

@Kaiepi Kaiepi force-pushed the ipv6-unsupported branch 4 times, most recently from 83b2633 to c8c4198 Compare September 6, 2019 18:33
@Kaiepi
Copy link
Contributor Author

Kaiepi commented Sep 6, 2019

I can't find any memory leaks specific to async sockets with OpenBSD's malloc_gdump anymore with the last commit (Valgrind complains about a missing syscall wrapper and bails with sockets tests on the only box I can run it on).

The last commit also includes some fixes to MVMROOTs in the async sockets files, since they weren't always being given every pointer known by whatever function it's used from that the GC keeps track of (hopefully I'm not on the wrong track here).

src/io/asyncsocket.c Outdated Show resolved Hide resolved
@Kaiepi
Copy link
Contributor Author

Kaiepi commented Sep 13, 2019

Fixed the GC issues I found with MVM_GC_DEBUG

This makes it so AI_ADDRCONFIG and AI_NUMERICSERV get used, which fixes
an issue where IPv6 addresses would still get resolved when IPv6 is
disabled, and makes it so getaddrinfo doesn't treat the port like a
service at first.
This fixes an issue where trying to connect to a host with AF_UNSPEC
using an IPv6 address first would never reattempt using an IPv4 address
when it inevitably fails if IPv6 support is enabled, but misconfigured.
Sometimes, async TCP sockets were being closed after they checked to see
if they were closed, but before actions on the socket were done.

Async sockets were not passing all the object pointers they have to
MVMROOT. which could possibly lead to them getting moved in the middle
of an op.

Roughly 500KB less memory gets leaked when simply binding an async TCP
socket, connecting to it, and echoing a message now. Doing the same
with async UDP sockets leaks around 2.5MB less memory.
@lizmat lizmat merged commit 39f5774 into MoarVM:master Oct 7, 2019
Kaiepi added a commit to Kaiepi/MoarVM that referenced this pull request Oct 24, 2019
While only the change to make all addresses get used when connecting or
binding sockets needs to be reverted from this, not every commit had
only one change included with it, making it impossible to tell if it had
truly been reverted or not. They will be remade later.

This reverts commit 39f5774, reversing
changes made to 01f85c8.
AlexDaniel added a commit that referenced this pull request Oct 26, 2019
Revert "Merge pull request #1166 from Kaiepi/ipv6-unsupported"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants