From bccd1ea5e8d4dbd4f1367946b22ea60efffd7b50 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Thu, 16 Jul 2020 21:30:13 +0000 Subject: [PATCH 1/4] Merged PR 9014: [2.1] Cancel SendFile copy loops There are two places in 2.1 where SendFileAsync falls back to a copy loop. These loops should short circuit when the client disconnects, or else the server will sit there and burn resources reading the whole file from disk. Fix: If you passed in your own active CT we'll use it. Otherwise we'll use the RequestAborted token. --- eng/PatchConfig.props | 2 + .../src/SendFileResponseExtensions.cs | 71 ++++++++++++------- ...ft.AspNetCore.Http.Extensions.Tests.csproj | 4 ++ .../test/SendFileResponseExtensionsTests.cs | 42 +++++++++++ src/Http/Http.Extensions/test/testfile1kb.txt | 1 + src/Http/HttpAbstractions.sln | 30 ++++++++ src/Middleware/Middleware.sln | 15 ++++ .../src/BodyWrapperStream.cs | 50 +++++++++++-- .../test/BodyWrapperStreamTests.cs | 18 ++++- 9 files changed, 200 insertions(+), 33 deletions(-) create mode 100644 src/Http/Http.Extensions/test/testfile1kb.txt diff --git a/eng/PatchConfig.props b/eng/PatchConfig.props index 3eb4d105ba43..6f17fb8dec12 100644 --- a/eng/PatchConfig.props +++ b/eng/PatchConfig.props @@ -68,6 +68,8 @@ Later on, this will be checked using this condition: + Microsoft.AspNetCore.Http.Extensions; + Microsoft.AspNetCore.ResponseCompression; diff --git a/src/Http/Http.Extensions/src/SendFileResponseExtensions.cs b/src/Http/Http.Extensions/src/SendFileResponseExtensions.cs index 74c0422ef41f..1ff159c7c9ee 100644 --- a/src/Http/Http.Extensions/src/SendFileResponseExtensions.cs +++ b/src/Http/Http.Extensions/src/SendFileResponseExtensions.cs @@ -107,41 +107,28 @@ public static Task SendFileAsync(this HttpResponse response, string fileName, lo private static async Task SendFileAsyncCore(HttpResponse response, IFileInfo file, long offset, long? count, CancellationToken cancellationToken) { - if (string.IsNullOrEmpty(file.PhysicalPath)) + if (!string.IsNullOrEmpty(file.PhysicalPath)) { - CheckRange(offset, count, file.Length); - - using (var fileContent = file.CreateReadStream()) - { - if (offset > 0) - { - fileContent.Seek(offset, SeekOrigin.Begin); - } - await StreamCopyOperation.CopyToAsync(fileContent, response.Body, count, cancellationToken); - } + await response.SendFileAsync(file.PhysicalPath, offset, count, cancellationToken); + return; } - else + + CheckRange(offset, count, file.Length); + using (var fileContent = file.CreateReadStream()) { - await response.SendFileAsync(file.PhysicalPath, offset, count, cancellationToken); + await SendStreamAsync(fileContent, response, offset, count, cancellationToken); } } - private static Task SendFileAsyncCore(HttpResponse response, string fileName, long offset, long? count, CancellationToken cancellationToken = default) + private static async Task SendFileAsyncCore(HttpResponse response, string fileName, long offset, long? count, CancellationToken cancellationToken = default) { var sendFile = response.HttpContext.Features.Get(); - if (sendFile == null) + if (sendFile != null) { - return SendFileAsyncCore(response.Body, fileName, offset, count, cancellationToken); + await sendFile.SendFileAsync(fileName, offset, count, cancellationToken); + return; } - return sendFile.SendFileAsync(fileName, offset, count, cancellationToken); - } - - // Not safe for overlapped writes. - private static async Task SendFileAsyncCore(Stream outputStream, string fileName, long offset, long? count, CancellationToken cancel = default) - { - cancel.ThrowIfCancellationRequested(); - var fileInfo = new FileInfo(fileName); CheckRange(offset, count, fileInfo.Length); @@ -155,14 +142,44 @@ private static async Task SendFileAsyncCore(Stream outputStream, string fileName options: FileOptions.Asynchronous | FileOptions.SequentialScan); using (fileStream) + { + await SendStreamAsync(fileStream, response, offset, count, cancellationToken); + } + } + + private static Task SendStreamAsync(Stream source, HttpResponse response, long offset, long? count, CancellationToken cancellationToken) + { + if (!cancellationToken.CanBeCanceled) + { + return SendStreamQuietAsync(source, response, offset, count, response.HttpContext.RequestAborted); + } + + cancellationToken.ThrowIfCancellationRequested(); + if (offset > 0) + { + source.Seek(offset, SeekOrigin.Begin); + } + + return StreamCopyOperation.CopyToAsync(source, response.Body, count, cancellationToken); + } + + private static async Task SendStreamQuietAsync(Stream source, HttpResponse response, long offset, long? count, CancellationToken cancellationToken) + { + if (cancellationToken.IsCancellationRequested) + { + return; + } + + try { if (offset > 0) { - fileStream.Seek(offset, SeekOrigin.Begin); + source.Seek(offset, SeekOrigin.Begin); } - await StreamCopyOperation.CopyToAsync(fileStream, outputStream, count, cancel); + await StreamCopyOperation.CopyToAsync(source, response.Body, count, cancellationToken); } + catch (OperationCanceledException) { } } private static void CheckRange(long offset, long? count, long fileLength) @@ -178,4 +195,4 @@ private static void CheckRange(long offset, long? count, long fileLength) } } } -} \ No newline at end of file +} diff --git a/src/Http/Http.Extensions/test/Microsoft.AspNetCore.Http.Extensions.Tests.csproj b/src/Http/Http.Extensions/test/Microsoft.AspNetCore.Http.Extensions.Tests.csproj index aa69c02d8ad2..d13e7555262c 100644 --- a/src/Http/Http.Extensions/test/Microsoft.AspNetCore.Http.Extensions.Tests.csproj +++ b/src/Http/Http.Extensions/test/Microsoft.AspNetCore.Http.Extensions.Tests.csproj @@ -4,6 +4,10 @@ netcoreapp2.1;net461 + + + + diff --git a/src/Http/Http.Extensions/test/SendFileResponseExtensionsTests.cs b/src/Http/Http.Extensions/test/SendFileResponseExtensionsTests.cs index f4c7c0f2a991..a763317ceaa2 100644 --- a/src/Http/Http.Extensions/test/SendFileResponseExtensionsTests.cs +++ b/src/Http/Http.Extensions/test/SendFileResponseExtensionsTests.cs @@ -1,5 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. +using System; using System.IO; using System.Threading; using System.Threading.Tasks; @@ -49,5 +50,46 @@ public Task SendFileAsync(string path, long offset, long? length, CancellationTo return Task.FromResult(0); } } + + [Fact] + public async Task SendFile_FallsBackToBodyStream() + { + var body = new MemoryStream(); + var context = new DefaultHttpContext(); + var response = context.Response; + response.Body = body; + + await response.SendFileAsync("testfile1kb.txt", 1, 3, CancellationToken.None); + + Assert.Equal(3, body.Length); + } + + [Fact] + public async Task SendFile_ThrowsWhenCanceled() + { + var body = new MemoryStream(); + var context = new DefaultHttpContext(); + var response = context.Response; + response.Body = body; + + await Assert.ThrowsAsync( + () => response.SendFileAsync("testfile1kb.txt", 1, 3, new CancellationToken(canceled: true))); + + Assert.Equal(0, body.Length); + } + + [Fact] + public async Task SendFile_AbortsSilentlyWhenRequestCanceled() + { + var body = new MemoryStream(); + var context = new DefaultHttpContext(); + context.RequestAborted = new CancellationToken(canceled: true); + var response = context.Response; + response.Body = body; + + await response.SendFileAsync("testfile1kb.txt", 1, 3, CancellationToken.None); + + Assert.Equal(0, body.Length); + } } } diff --git a/src/Http/Http.Extensions/test/testfile1kb.txt b/src/Http/Http.Extensions/test/testfile1kb.txt new file mode 100644 index 000000000000..24baa4c60865 --- /dev/null +++ b/src/Http/Http.Extensions/test/testfile1kb.txt @@ -0,0 +1 @@ +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \ No newline at end of file diff --git a/src/Http/HttpAbstractions.sln b/src/Http/HttpAbstractions.sln index 17e89b8deae7..6e2a5eabbf0e 100644 --- a/src/Http/HttpAbstractions.sln +++ b/src/Http/HttpAbstractions.sln @@ -81,6 +81,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RoutingSample.Web", "Routin EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dependencies", "dependencies", "{793FFE24-138A-4C3D-81AB-18D625E36230}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Server.Kestrel", "..\Servers\Kestrel\Kestrel\src\Microsoft.AspNetCore.Server.Kestrel.csproj", "{C2608BEB-0C4C-4EDB-A0E4-E29AE59B4566}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Server.IISIntegration", "..\Servers\IIS\IISIntegration\src\Microsoft.AspNetCore.Server.IISIntegration.csproj", "{11E37916-24DF-48A3-AFC9-9E9BB76588E4}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -403,6 +407,30 @@ Global {F4F5D8AF-FBD1-463F-9473-B63AA820A6C4}.Release|x64.Build.0 = Release|Any CPU {F4F5D8AF-FBD1-463F-9473-B63AA820A6C4}.Release|x86.ActiveCfg = Release|Any CPU {F4F5D8AF-FBD1-463F-9473-B63AA820A6C4}.Release|x86.Build.0 = Release|Any CPU + {C2608BEB-0C4C-4EDB-A0E4-E29AE59B4566}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C2608BEB-0C4C-4EDB-A0E4-E29AE59B4566}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C2608BEB-0C4C-4EDB-A0E4-E29AE59B4566}.Debug|x64.ActiveCfg = Debug|Any CPU + {C2608BEB-0C4C-4EDB-A0E4-E29AE59B4566}.Debug|x64.Build.0 = Debug|Any CPU + {C2608BEB-0C4C-4EDB-A0E4-E29AE59B4566}.Debug|x86.ActiveCfg = Debug|Any CPU + {C2608BEB-0C4C-4EDB-A0E4-E29AE59B4566}.Debug|x86.Build.0 = Debug|Any CPU + {C2608BEB-0C4C-4EDB-A0E4-E29AE59B4566}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C2608BEB-0C4C-4EDB-A0E4-E29AE59B4566}.Release|Any CPU.Build.0 = Release|Any CPU + {C2608BEB-0C4C-4EDB-A0E4-E29AE59B4566}.Release|x64.ActiveCfg = Release|Any CPU + {C2608BEB-0C4C-4EDB-A0E4-E29AE59B4566}.Release|x64.Build.0 = Release|Any CPU + {C2608BEB-0C4C-4EDB-A0E4-E29AE59B4566}.Release|x86.ActiveCfg = Release|Any CPU + {C2608BEB-0C4C-4EDB-A0E4-E29AE59B4566}.Release|x86.Build.0 = Release|Any CPU + {11E37916-24DF-48A3-AFC9-9E9BB76588E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {11E37916-24DF-48A3-AFC9-9E9BB76588E4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {11E37916-24DF-48A3-AFC9-9E9BB76588E4}.Debug|x64.ActiveCfg = Debug|Any CPU + {11E37916-24DF-48A3-AFC9-9E9BB76588E4}.Debug|x64.Build.0 = Debug|Any CPU + {11E37916-24DF-48A3-AFC9-9E9BB76588E4}.Debug|x86.ActiveCfg = Debug|Any CPU + {11E37916-24DF-48A3-AFC9-9E9BB76588E4}.Debug|x86.Build.0 = Debug|Any CPU + {11E37916-24DF-48A3-AFC9-9E9BB76588E4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {11E37916-24DF-48A3-AFC9-9E9BB76588E4}.Release|Any CPU.Build.0 = Release|Any CPU + {11E37916-24DF-48A3-AFC9-9E9BB76588E4}.Release|x64.ActiveCfg = Release|Any CPU + {11E37916-24DF-48A3-AFC9-9E9BB76588E4}.Release|x64.Build.0 = Release|Any CPU + {11E37916-24DF-48A3-AFC9-9E9BB76588E4}.Release|x86.ActiveCfg = Release|Any CPU + {11E37916-24DF-48A3-AFC9-9E9BB76588E4}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -435,6 +463,8 @@ Global {E4AC79A3-625B-421B-9F91-EFCBD9BEB37F} = {24D19E8E-25FD-4C0B-8865-697878B67BE0} {BF8DC0FF-96F9-4705-8CFA-F42BE989AB6A} = {793FFE24-138A-4C3D-81AB-18D625E36230} {F4F5D8AF-FBD1-463F-9473-B63AA820A6C4} = {14A7B3DE-46C8-4245-B0BD-9AFF3795C163} + {C2608BEB-0C4C-4EDB-A0E4-E29AE59B4566} = {793FFE24-138A-4C3D-81AB-18D625E36230} + {11E37916-24DF-48A3-AFC9-9E9BB76588E4} = {793FFE24-138A-4C3D-81AB-18D625E36230} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {85B5E151-2E9D-419C-83DD-0DDCF446C83A} diff --git a/src/Middleware/Middleware.sln b/src/Middleware/Middleware.sln index e861bd87a8f6..111573a9c9ae 100644 --- a/src/Middleware/Middleware.sln +++ b/src/Middleware/Middleware.sln @@ -191,6 +191,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Server EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_dependencies", "_dependencies", "{ACA6DDB9-7592-47CE-A740-D15BF307E9E0}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Server.IISIntegration", "..\Servers\IIS\IISIntegration\src\Microsoft.AspNetCore.Server.IISIntegration.csproj", "{F05215CF-F754-47BF-ACED-259C53C8B223}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1005,6 +1007,18 @@ Global {260E77CB-800F-4A13-BE92-9CAA097705C2}.Release|x64.Build.0 = Release|Any CPU {260E77CB-800F-4A13-BE92-9CAA097705C2}.Release|x86.ActiveCfg = Release|Any CPU {260E77CB-800F-4A13-BE92-9CAA097705C2}.Release|x86.Build.0 = Release|Any CPU + {F05215CF-F754-47BF-ACED-259C53C8B223}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F05215CF-F754-47BF-ACED-259C53C8B223}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F05215CF-F754-47BF-ACED-259C53C8B223}.Debug|x64.ActiveCfg = Debug|Any CPU + {F05215CF-F754-47BF-ACED-259C53C8B223}.Debug|x64.Build.0 = Debug|Any CPU + {F05215CF-F754-47BF-ACED-259C53C8B223}.Debug|x86.ActiveCfg = Debug|Any CPU + {F05215CF-F754-47BF-ACED-259C53C8B223}.Debug|x86.Build.0 = Debug|Any CPU + {F05215CF-F754-47BF-ACED-259C53C8B223}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F05215CF-F754-47BF-ACED-259C53C8B223}.Release|Any CPU.Build.0 = Release|Any CPU + {F05215CF-F754-47BF-ACED-259C53C8B223}.Release|x64.ActiveCfg = Release|Any CPU + {F05215CF-F754-47BF-ACED-259C53C8B223}.Release|x64.Build.0 = Release|Any CPU + {F05215CF-F754-47BF-ACED-259C53C8B223}.Release|x86.ActiveCfg = Release|Any CPU + {F05215CF-F754-47BF-ACED-259C53C8B223}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1086,6 +1100,7 @@ Global {0186A5D0-6D05-4C19-BB81-E49A51745FFF} = {ACA6DDB9-7592-47CE-A740-D15BF307E9E0} {17B7BFF6-4E72-410C-B690-02741505500A} = {ACA6DDB9-7592-47CE-A740-D15BF307E9E0} {260E77CB-800F-4A13-BE92-9CAA097705C2} = {ACA6DDB9-7592-47CE-A740-D15BF307E9E0} + {F05215CF-F754-47BF-ACED-259C53C8B223} = {ACA6DDB9-7592-47CE-A740-D15BF307E9E0} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {83786312-A93B-4BB4-AB06-7C6913A59AFA} diff --git a/src/Middleware/ResponseCompression/src/BodyWrapperStream.cs b/src/Middleware/ResponseCompression/src/BodyWrapperStream.cs index d315d82dfad7..ee84b4933820 100644 --- a/src/Middleware/ResponseCompression/src/BodyWrapperStream.cs +++ b/src/Middleware/ResponseCompression/src/BodyWrapperStream.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// 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; @@ -286,10 +286,8 @@ public Task SendFileAsync(string path, long offset, long? count, CancellationTok return _innerSendFileFeature.SendFileAsync(path, offset, count, cancellation); } - private async Task InnerSendFileAsync(string path, long offset, long? count, CancellationToken cancellation) + private Task InnerSendFileAsync(string path, long offset, long? count, CancellationToken cancellation) { - cancellation.ThrowIfCancellationRequested(); - var fileInfo = new FileInfo(path); if (offset < 0 || offset > fileInfo.Length) { @@ -311,9 +309,25 @@ private async Task InnerSendFileAsync(string path, long offset, long? count, Can bufferSize: bufferSize, options: FileOptions.Asynchronous | FileOptions.SequentialScan); + if (cancellation.CanBeCanceled) + { + return InnerSendFileLoudAsync(fileStream, offset, count, cancellation); + } + + return InnerSendFileQuietAsync(fileStream, offset, count, _context.RequestAborted); + } + + private async Task InnerSendFileLoudAsync(Stream fileStream, long offset, long? count, CancellationToken cancellation) + { using (fileStream) { - fileStream.Seek(offset, SeekOrigin.Begin); + cancellation.ThrowIfCancellationRequested(); + + if (offset > 0) + { + fileStream.Seek(offset, SeekOrigin.Begin); + } + await StreamCopyOperation.CopyToAsync(fileStream, _compressionStream, count, cancellation); if (_autoFlush) @@ -322,5 +336,31 @@ private async Task InnerSendFileAsync(string path, long offset, long? count, Can } } } + + private async Task InnerSendFileQuietAsync(Stream fileStream, long offset, long? count, CancellationToken cancellation) + { + try + { + if (!cancellation.IsCancellationRequested) + { + if (offset > 0) + { + fileStream.Seek(offset, SeekOrigin.Begin); + } + + await StreamCopyOperation.CopyToAsync(fileStream, _compressionStream, count, cancellation); + + if (_autoFlush) + { + await _compressionStream.FlushAsync(cancellation); + } + } + } + catch (OperationCanceledException) { } + finally + { + fileStream.Dispose(); + } + } } } diff --git a/src/Middleware/ResponseCompression/test/BodyWrapperStreamTests.cs b/src/Middleware/ResponseCompression/test/BodyWrapperStreamTests.cs index 4ffd70b745e3..15351cd4282e 100644 --- a/src/Middleware/ResponseCompression/test/BodyWrapperStreamTests.cs +++ b/src/Middleware/ResponseCompression/test/BodyWrapperStreamTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// 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; @@ -90,6 +90,22 @@ public async Task SendFileAsync_IsPassedToUnderlyingStream_WhenDisableResponseBu Assert.Equal(File.ReadAllBytes(path), memoryStream.ToArray()); } + [Fact] + public async Task SendFileAsync_SkipsSilently_WhenRequestAborted() + { + var memoryStream = new MemoryStream(); + + var context = new DefaultHttpContext(); + context.RequestAborted = new CancellationToken(canceled: true); + var stream = new BodyWrapperStream(context, memoryStream, new MockResponseCompressionProvider(true), null, null); + + var path = "testfile1kb.txt"; + await stream.SendFileAsync(path, 0, null, CancellationToken.None); + stream.Flush(); + + Assert.Equal(0, memoryStream.Length); + } + [Theory] [InlineData(true)] [InlineData(false)] From 2cb52f06b229b4c92e6429eeb621608fa1fcfdb1 Mon Sep 17 00:00:00 2001 From: Doug Bunting <6431421+dougbu@users.noreply.github.com> Date: Tue, 11 Aug 2020 21:19:18 -0700 Subject: [PATCH 2/4] Update branding to 2.1.22 --- eng/Baseline.Designer.props | 10 +++++----- eng/Baseline.xml | 6 +++--- eng/PatchConfig.props | 4 ++++ .../ArchiveBaseline.2.1.21.txt | 1 + .../Archive.CiServer.Patch/ArchiveBaseline.2.1.21.txt | 1 + version.props | 2 +- 6 files changed, 15 insertions(+), 9 deletions(-) create mode 100644 src/PackageArchive/Archive.CiServer.Patch.Compat/ArchiveBaseline.2.1.21.txt create mode 100644 src/PackageArchive/Archive.CiServer.Patch/ArchiveBaseline.2.1.21.txt diff --git a/eng/Baseline.Designer.props b/eng/Baseline.Designer.props index 11119cef2fcc..0060a1c36124 100644 --- a/eng/Baseline.Designer.props +++ b/eng/Baseline.Designer.props @@ -2,7 +2,7 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.20 + 2.1.21 @@ -477,13 +477,13 @@ - 2.1.1 + 2.1.21 - - + + @@ -859,7 +859,7 @@ - 2.1.1 + 2.1.21 diff --git a/eng/Baseline.xml b/eng/Baseline.xml index 398381dcad0e..ce240e5f6944 100644 --- a/eng/Baseline.xml +++ b/eng/Baseline.xml @@ -4,7 +4,7 @@ This file contains a list of all the packages and their versions which were rele build of ASP.NET Core 2.1.x. Update this list when preparing for a new patch. --> - + @@ -54,7 +54,7 @@ build of ASP.NET Core 2.1.x. Update this list when preparing for a new patch. - + @@ -93,7 +93,7 @@ build of ASP.NET Core 2.1.x. Update this list when preparing for a new patch. - + diff --git a/eng/PatchConfig.props b/eng/PatchConfig.props index 6f17fb8dec12..40c0413b43b3 100644 --- a/eng/PatchConfig.props +++ b/eng/PatchConfig.props @@ -72,4 +72,8 @@ Later on, this will be checked using this condition: Microsoft.AspNetCore.ResponseCompression; + + + + diff --git a/src/PackageArchive/Archive.CiServer.Patch.Compat/ArchiveBaseline.2.1.21.txt b/src/PackageArchive/Archive.CiServer.Patch.Compat/ArchiveBaseline.2.1.21.txt new file mode 100644 index 000000000000..8b137891791f --- /dev/null +++ b/src/PackageArchive/Archive.CiServer.Patch.Compat/ArchiveBaseline.2.1.21.txt @@ -0,0 +1 @@ + diff --git a/src/PackageArchive/Archive.CiServer.Patch/ArchiveBaseline.2.1.21.txt b/src/PackageArchive/Archive.CiServer.Patch/ArchiveBaseline.2.1.21.txt new file mode 100644 index 000000000000..8b137891791f --- /dev/null +++ b/src/PackageArchive/Archive.CiServer.Patch/ArchiveBaseline.2.1.21.txt @@ -0,0 +1 @@ + diff --git a/version.props b/version.props index e0df5c7e110c..684ab9f01130 100644 --- a/version.props +++ b/version.props @@ -2,7 +2,7 @@ 2 1 - 21 + 22 servicing Servicing t000 From 7fc3da231c4e14c251584bd324a3f08f12f4b763 Mon Sep 17 00:00:00 2001 From: Doug Bunting <6431421+dougbu@users.noreply.github.com> Date: Tue, 11 Aug 2020 21:30:24 -0700 Subject: [PATCH 3/4] Update EF submodule --- modules/EntityFrameworkCore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/EntityFrameworkCore b/modules/EntityFrameworkCore index e7a4277846e7..1e01d4f9c2e8 160000 --- a/modules/EntityFrameworkCore +++ b/modules/EntityFrameworkCore @@ -1 +1 @@ -Subproject commit e7a4277846e720fb8a5729c2a3de98c4c2ff67e5 +Subproject commit 1e01d4f9c2e8727c9b475552025b2d493993045d From 06f86cd6430da9eeab875da06e2ff22d43a184ad Mon Sep 17 00:00:00 2001 From: Doug Bunting <6431421+dougbu@users.noreply.github.com> Date: Wed, 12 Aug 2020 10:41:54 -0700 Subject: [PATCH 4/4] Do not run hostname tests on macOS - ports 522088b6be to this branch --- .../TransportTestHelpers/HostNameIsReachableAttribute.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Servers/Kestrel/shared/test/TransportTestHelpers/HostNameIsReachableAttribute.cs b/src/Servers/Kestrel/shared/test/TransportTestHelpers/HostNameIsReachableAttribute.cs index 5a83bd7c3f88..72415db043fb 100644 --- a/src/Servers/Kestrel/shared/test/TransportTestHelpers/HostNameIsReachableAttribute.cs +++ b/src/Servers/Kestrel/shared/test/TransportTestHelpers/HostNameIsReachableAttribute.cs @@ -4,6 +4,7 @@ using System; using System.Net; using System.Net.Sockets; +using System.Runtime.InteropServices; using System.Threading.Tasks; using Microsoft.AspNetCore.Testing.xunit; @@ -30,6 +31,12 @@ public bool IsMet private async Task HostNameIsReachable() { + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + // Code below is unreliable on macOS and tests fail on that platform. + return false; + } + try { _hostname = Dns.GetHostName();