From 7a9160f3e0e3782eff60f8a8e0496332d2bcadf6 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Tue, 27 Mar 2018 02:02:29 -0700 Subject: [PATCH] React to https://github.com/aspnet/KestrelHttpServer/pull/2428 (#1734) --- ....AspNetCore.SignalR.Microbenchmarks.csproj | 4 ++ build/dependencies.props | 4 +- src/Common/DuplexPipe.cs | 41 +++++++++++++++++++ ...soft.AspNetCore.Sockets.Client.Http.csproj | 1 + .../Microsoft.AspNetCore.Sockets.Http.csproj | 1 + ...oft.AspNetCore.SignalR.Client.Tests.csproj | 4 ++ ...soft.AspNetCore.SignalR.Tests.Utils.csproj | 4 ++ .../Microsoft.AspNetCore.SignalR.Tests.csproj | 4 ++ .../Microsoft.AspNetCore.Sockets.Tests.csproj | 4 ++ 9 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 src/Common/DuplexPipe.cs diff --git a/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks.csproj b/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks.csproj index 646477a011..33d46900d9 100644 --- a/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks.csproj +++ b/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks.csproj @@ -5,6 +5,10 @@ netcoreapp2.1 + + + + diff --git a/build/dependencies.props b/build/dependencies.props index 18f2d9e075..f1dd64459c 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -12,7 +12,7 @@ 2.1.0-preview2-30451 2.1.0-preview2-30451 2.1.0-preview2-30451 - 2.1.0-preview2-30451 + 2.1.0-a-preview2-remove-duplex-pipe-17616 2.1.0-preview2-30451 2.1.0-preview2-30451 2.1.0-preview2-30451 @@ -26,7 +26,7 @@ 2.1.0-preview2-30451 2.1.0-preview2-30451 0.5.0-preview2-30451 - 2.1.0-preview2-30451 + 2.1.0-a-preview2-remove-duplex-pipe-17616 2.1.0-preview2-30451 2.1.0-preview2-30451 2.1.0-preview2-30451 diff --git a/src/Common/DuplexPipe.cs b/src/Common/DuplexPipe.cs new file mode 100644 index 0000000000..4fc01d01f5 --- /dev/null +++ b/src/Common/DuplexPipe.cs @@ -0,0 +1,41 @@ +using System.Buffers; + +namespace System.IO.Pipelines +{ + internal class DuplexPipe : IDuplexPipe + { + public DuplexPipe(PipeReader reader, PipeWriter writer) + { + Input = reader; + Output = writer; + } + + public PipeReader Input { get; } + + public PipeWriter Output { get; } + + public static DuplexPipePair CreateConnectionPair(PipeOptions inputOptions, PipeOptions outputOptions) + { + var input = new Pipe(inputOptions); + var output = new Pipe(outputOptions); + + var transportToApplication = new DuplexPipe(output.Reader, input.Writer); + var applicationToTransport = new DuplexPipe(input.Reader, output.Writer); + + return new DuplexPipePair(applicationToTransport, transportToApplication); + } + + // This class exists to work around issues with value tuple on .NET Framework + public readonly struct DuplexPipePair + { + public IDuplexPipe Transport { get; } + public IDuplexPipe Application { get; } + + public DuplexPipePair(IDuplexPipe transport, IDuplexPipe application) + { + Transport = transport; + Application = application; + } + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Sockets.Client.Http/Microsoft.AspNetCore.Sockets.Client.Http.csproj b/src/Microsoft.AspNetCore.Sockets.Client.Http/Microsoft.AspNetCore.Sockets.Client.Http.csproj index 3d367e968f..2a071e0bad 100644 --- a/src/Microsoft.AspNetCore.Sockets.Client.Http/Microsoft.AspNetCore.Sockets.Client.Http.csproj +++ b/src/Microsoft.AspNetCore.Sockets.Client.Http/Microsoft.AspNetCore.Sockets.Client.Http.csproj @@ -10,6 +10,7 @@ + diff --git a/src/Microsoft.AspNetCore.Sockets.Http/Microsoft.AspNetCore.Sockets.Http.csproj b/src/Microsoft.AspNetCore.Sockets.Http/Microsoft.AspNetCore.Sockets.Http.csproj index 6c12890f74..e9142d0abd 100644 --- a/src/Microsoft.AspNetCore.Sockets.Http/Microsoft.AspNetCore.Sockets.Http.csproj +++ b/src/Microsoft.AspNetCore.Sockets.Http/Microsoft.AspNetCore.Sockets.Http.csproj @@ -9,6 +9,7 @@ + diff --git a/test/Microsoft.AspNetCore.SignalR.Client.Tests/Microsoft.AspNetCore.SignalR.Client.Tests.csproj b/test/Microsoft.AspNetCore.SignalR.Client.Tests/Microsoft.AspNetCore.SignalR.Client.Tests.csproj index ac67f9b7a7..7731393e9d 100644 --- a/test/Microsoft.AspNetCore.SignalR.Client.Tests/Microsoft.AspNetCore.SignalR.Client.Tests.csproj +++ b/test/Microsoft.AspNetCore.SignalR.Client.Tests/Microsoft.AspNetCore.SignalR.Client.Tests.csproj @@ -10,6 +10,10 @@ + + + + diff --git a/test/Microsoft.AspNetCore.SignalR.Tests.Utils/Microsoft.AspNetCore.SignalR.Tests.Utils.csproj b/test/Microsoft.AspNetCore.SignalR.Tests.Utils/Microsoft.AspNetCore.SignalR.Tests.Utils.csproj index d9690b6657..4e4b124472 100644 --- a/test/Microsoft.AspNetCore.SignalR.Tests.Utils/Microsoft.AspNetCore.SignalR.Tests.Utils.csproj +++ b/test/Microsoft.AspNetCore.SignalR.Tests.Utils/Microsoft.AspNetCore.SignalR.Tests.Utils.csproj @@ -5,6 +5,10 @@ Microsoft.AspNetCore.SignalR.Tests + + + + diff --git a/test/Microsoft.AspNetCore.SignalR.Tests/Microsoft.AspNetCore.SignalR.Tests.csproj b/test/Microsoft.AspNetCore.SignalR.Tests/Microsoft.AspNetCore.SignalR.Tests.csproj index d6da59a690..c23bdb901f 100644 --- a/test/Microsoft.AspNetCore.SignalR.Tests/Microsoft.AspNetCore.SignalR.Tests.csproj +++ b/test/Microsoft.AspNetCore.SignalR.Tests/Microsoft.AspNetCore.SignalR.Tests.csproj @@ -21,6 +21,10 @@ + + + + diff --git a/test/Microsoft.AspNetCore.Sockets.Tests/Microsoft.AspNetCore.Sockets.Tests.csproj b/test/Microsoft.AspNetCore.Sockets.Tests/Microsoft.AspNetCore.Sockets.Tests.csproj index c743871b69..d4fbac0ce0 100644 --- a/test/Microsoft.AspNetCore.Sockets.Tests/Microsoft.AspNetCore.Sockets.Tests.csproj +++ b/test/Microsoft.AspNetCore.Sockets.Tests/Microsoft.AspNetCore.Sockets.Tests.csproj @@ -11,6 +11,10 @@ + + + +