This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Modified Dns.GetHostAddressesAsync to be truly async #26850
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e31d807
Modified Dns.GetHostAddressesAsync to be truly async
JeffCyr 77ccb1c
Applied code review recommendations
JeffCyr a6cff67
Unix build fix
JeffCyr 898719f
Unix build fix #2
JeffCyr c173a88
Unix build fix #3
JeffCyr a375f91
NETFX build fix
JeffCyr 795e5be
Fixed useGetHostByName logic
JeffCyr a9a3403
Simplified ProcessResult code
JeffCyr 91864e5
Cleaned up cancel code
JeffCyr 524b5fa
cleanup
JeffCyr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Net.Internals; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace System.Net.Sockets | ||
{ | ||
[StructLayout(LayoutKind.Sequential)] | ||
internal unsafe struct AddressInfoEx | ||
{ | ||
internal AddressInfoHints ai_flags; | ||
internal AddressFamily ai_family; | ||
internal SocketType ai_socktype; | ||
internal ProtocolFamily ai_protocol; | ||
internal int ai_addrlen; | ||
internal IntPtr ai_canonname; // Ptr to the canonical name - check for NULL | ||
internal byte* ai_addr; // Ptr to the sockaddr structure | ||
internal IntPtr ai_blob; // Unused ptr to blob data about provider | ||
internal int ai_bloblen; | ||
internal IntPtr ai_provider; // Unused ptr to the namespace provider guid | ||
internal AddressInfoEx* ai_next; // Next structure in linked list | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/Common/src/Interop/Windows/Winsock/Interop.GetAddrInfoExW.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Net.Sockets; | ||
using System.Runtime.InteropServices; | ||
using System.Threading; | ||
|
||
internal static partial class Interop | ||
{ | ||
internal static partial class Winsock | ||
{ | ||
internal const string GetAddrInfoExCancelFunctionName = "GetAddrInfoExCancel"; | ||
|
||
internal unsafe delegate void LPLOOKUPSERVICE_COMPLETION_ROUTINE([In] int dwError, [In] int dwBytes, [In] NativeOverlapped* lpOverlapped); | ||
|
||
[DllImport(Interop.Libraries.Ws2_32, ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)] | ||
internal static extern unsafe int GetAddrInfoExW( | ||
[In] string pName, | ||
[In] string pServiceName, | ||
[In] int dwNamespace, | ||
[In] IntPtr lpNspId, | ||
[In] ref AddressInfoEx pHints, | ||
[Out] out AddressInfoEx* ppResult, | ||
[In] IntPtr timeout, | ||
[In] ref NativeOverlapped lpOverlapped, | ||
[In] LPLOOKUPSERVICE_COMPLETION_ROUTINE lpCompletionRoutine, | ||
[Out] out IntPtr lpNameHandle | ||
); | ||
|
||
[DllImport("ws2_32.dll", ExactSpelling = true, SetLastError = true)] | ||
internal static extern unsafe void FreeAddrInfoEx([In] AddressInfoEx* pAddrInfo); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/System.Net.NameResolution/src/System/Net/DnsResolveAsyncResult.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace System.Net | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing license header There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
{ | ||
internal sealed class DnsResolveAsyncResult : ContextAwareResult | ||
{ | ||
internal string HostName { get; } | ||
internal bool IncludeIPv6 { get; } | ||
internal IPAddress IpAddress { get; } | ||
|
||
// Forward lookup | ||
internal DnsResolveAsyncResult(string hostName, object myObject, bool includeIPv6, object myState, AsyncCallback myCallBack) | ||
: base(myObject, myState, myCallBack) | ||
{ | ||
HostName = hostName; | ||
IncludeIPv6 = includeIPv6; | ||
} | ||
|
||
// Reverse lookup | ||
internal DnsResolveAsyncResult(IPAddress ipAddress, object myObject, bool includeIPv6, object myState, AsyncCallback myCallBack) | ||
: base(myObject, myState, myCallBack) | ||
{ | ||
IncludeIPv6 = includeIPv6; | ||
IpAddress = ipAddress; | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing license header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done