Skip to content

Report the proper socket error #897

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

Merged
merged 1 commit into from
Apr 5, 2018
Merged

Conversation

joshpeterson
Copy link

When a connection fails, the socket error was being incorrectly reported
as an address family not supported error, instead of connection refused.

It looks like this happened between
c4e698c (Unity 2018.1b5), where the
proper error was reported, and ec98a4e
(Unity 2018.1b6), there the incorrect error is reported.

Why did this happen? Between those two changesets (there are about 180
intervening changesets), the order of addresses returned from
Dns.GetHostAddresses changed. The newer code returns the IPv6 address
first, and the IPv4 address second. While GetCheckedIPs mentioned in a
comment that it skips addresses that don't match the address family, it
did not. The code using the addresses returned by GetCheckedIPs will
use the first address in the array. If this address happens to match the
address family of the socket, things will work "properly" (the correct
socket error will occur).

If, however the first entry has the wrong address family, then the
socket error will be an address family not supported error, since the
socket was created with different address family.

This change modifies GetCheckedIPs to filter the addresses, removing
those which do not match the address family.

This corrects Unity case 1012875.

Release notes:
Scripting: Provide the proper socket error when an IPv4 connection is refused.

Should we back port this change? I think it should go to 2018.1. Also, should we upstream this? I think that we should.

When a connection fails, the socket error was being incorrectly reported
as an address family not supported error, instead of connection refused.

It looks like this happened between
c4e698c (Unity 2018.1b5), where the
proper error was reported, and ec98a4e
(Unity 2018.1b6), there the incorrect error is reported.

Why did this happen? Between those two changesets (there are about 180
intervening changesets), the order of addresses returned from
`Dns.GetHostAddresses` changed. The newer code returns the IPv6 address
first, and the IPv4 address second. While `GetCheckedIPs` mentioned in a
comment that it skips addresses that don't match the address family, it
did not. The code using the addresses returned by `GetCheckedIPs` will
use the first address in the array. If this address happens to match the
address family of the socket, things will work "properly" (the correct
socket error will occur).

If, however the first entry has the wrong address family, then the
socket error will be an address family not supported error, since the
socket was created with different address family.

This change modifies `GetCheckedIPs` to filter the addresses, removing
those which do not match the address family.

This corrects Unity case 1012875.
@joshpeterson joshpeterson requested review from joncham and mderoy March 30, 2018 19:34
@joshpeterson joshpeterson merged commit 17a6516 into unity-master Apr 5, 2018
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.

3 participants