Fix scope id test failures on mac and linux (#1754)

This commit is contained in:
Stephen Halter 2017-04-24 17:15:41 -07:00 committed by GitHub
parent 39047638cc
commit f26c31c116
3 changed files with 21 additions and 3 deletions

View File

@ -93,7 +93,20 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networkin
*((long*)(b + 8)) = _field2;
}
return new IPEndPoint(new IPAddress(bytes, scopeid: _field3 & 0xFFFFFFFF), port);
return new IPEndPoint(new IPAddress(bytes, ScopeId), port);
}
}
public uint ScopeId
{
get
{
return (uint)_field3;
}
set
{
_field3 &= unchecked ((long)0xFFFFFFFF00000000);
_field3 |= value;
}
}

View File

@ -44,6 +44,13 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networkin
{
throw error1;
}
if (endPoint.Address.ScopeId != addr.ScopeId)
{
// IPAddress.ScopeId cannot be less than 0 or greater than 0xFFFFFFFF
// https://msdn.microsoft.com/en-us/library/system.net.ipaddress.scopeid(v=vs.110).aspx
addr.ScopeId = (uint)endPoint.Address.ScopeId;
}
}
_uv.tcp_bind(this, ref addr, 0);

View File

@ -109,8 +109,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
[ConditionalTheory, MemberData(nameof(AddressRegistrationDataIPv6ScopeId))]
[IPv6SupportedCondition]
[IPv6ScopeIdPresentCondition]
[OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Causing test failures")]
[OSSkipCondition(OperatingSystems.Linux, SkipReason = "Causing test failures")]
public async Task RegisterAddresses_IPv6ScopeId_Success(string addressInput, Func<IServerAddressesFeature, string[]> testUrls)
{
await RegisterAddresses_Success(addressInput, testUrls);