This repository was archived by the owner on Dec 18, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 515
Enable TCP Loopback Fast Path (Windows) #416
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 hidden or 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
35 changes: 35 additions & 0 deletions
35
test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/TestConnection.cs
This file contains hidden or 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,35 @@ | ||
| // Copyright (c) .NET Foundation. All rights reserved. | ||
| // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
|
||
| using System; | ||
| using System.Net; | ||
| using System.Net.Sockets; | ||
| using Microsoft.AspNetCore.Server.Kestrel.Networking; | ||
|
|
||
| namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests | ||
| { | ||
| public class TestConnection | ||
| { | ||
| public static Socket CreateConnectedLoopbackSocket(int port) | ||
| { | ||
| var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); | ||
| if (PlatformApis.IsWindows) | ||
| { | ||
| const int SIO_LOOPBACK_FAST_PATH = -1744830448; | ||
| var optionInValue = BitConverter.GetBytes(1); | ||
| try | ||
| { | ||
| socket.IOControl(SIO_LOOPBACK_FAST_PATH, optionInValue, null); | ||
| } | ||
| catch | ||
| { | ||
| // If the operating system version on this machine did | ||
| // not support SIO_LOOPBACK_FAST_PATH (i.e. version | ||
| // prior to Windows 8 / Windows Server 2012), handle the exception | ||
| } | ||
| } | ||
| socket.Connect(new IPEndPoint(IPAddress.Loopback, port)); | ||
| return socket; | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
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.
This is only used on Darwin Mono so may not be needed if the feature is windows specific...
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.
Would end up with mismatched function implements? So if someone did want to use the
filenoin future calling the function on darwin mono would return incorrect info (if replaced with a dummy function)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.
If they need it they would have to add them. I don't really care too much - the
__Internalis going away soon. It won't/can't work with dotnet and even now when using dotnet the regular DllImports are being used on Mac on Mono.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.
I mean, I don't know what the
uv_filenofunction should resolve to on Darwin Mono if taken out.With this in it resolves to the libuv function - if I take it out should it resolve to a function shim with body:
throw new NotImplementedExecption("Libuv function not mapped on on Darwin Mono")?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.
I think you are right. It's better and easier to have
uv_filenoin __Internal just as any other function than do a special dance just to avoid it.