Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordotnet-bot <dotnet-bot@microsoft.com>2022-04-13 19:47:07 +0300
committerdotnet-bot <dotnet-bot@microsoft.com>2022-04-13 19:47:07 +0300
commit70ae3df4a6f3c92fb6b315afc405edd10ff38579 (patch)
treea934a29bc42df4f75c9d963b1a04f981439d2925
parent46f651346e970215755d13698e8d99a96541fb7f (diff)
parenta21b9a2dd4c31cf5bd37626562b7612faf21cee6 (diff)
Merge in 'release/6.0' changesv6.0.5
-rw-r--r--src/libraries/System.IO.Pipelines/src/System.IO.Pipelines.csproj3
-rw-r--r--src/libraries/System.IO.Pipelines/src/System/IO/Pipelines/Pipe.cs9
-rw-r--r--src/libraries/System.IO.Pipelines/tests/PipeReaderReadAtLeastAsyncTests.cs31
-rw-r--r--src/libraries/System.Text.Json/src/System.Text.Json.csproj3
-rw-r--r--src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.Converters.cs7
5 files changed, 45 insertions, 8 deletions
diff --git a/src/libraries/System.IO.Pipelines/src/System.IO.Pipelines.csproj b/src/libraries/System.IO.Pipelines/src/System.IO.Pipelines.csproj
index ec9632c4d1f..9e3f41ee823 100644
--- a/src/libraries/System.IO.Pipelines/src/System.IO.Pipelines.csproj
+++ b/src/libraries/System.IO.Pipelines/src/System.IO.Pipelines.csproj
@@ -9,7 +9,8 @@ Commonly Used Types:
System.IO.Pipelines.Pipe
System.IO.Pipelines.PipeWriter
System.IO.Pipelines.PipeReader</PackageDescription>
- <ServicingVersion>2</ServicingVersion>
+ <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
+ <ServicingVersion>3</ServicingVersion>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(CommonPath)System\Threading\Tasks\TaskToApm.cs"
diff --git a/src/libraries/System.IO.Pipelines/src/System/IO/Pipelines/Pipe.cs b/src/libraries/System.IO.Pipelines/src/System/IO/Pipelines/Pipe.cs
index d9b0b8c7a99..0c743f4c74a 100644
--- a/src/libraries/System.IO.Pipelines/src/System/IO/Pipelines/Pipe.cs
+++ b/src/libraries/System.IO.Pipelines/src/System/IO/Pipelines/Pipe.cs
@@ -347,7 +347,7 @@ namespace System.IO.Pipelines
ValueTask<FlushResult> result;
lock (SyncObj)
{
- PrepareFlush(out completionData, out result, cancellationToken);
+ PrepareFlushUnsynchronized(out completionData, out result, cancellationToken);
}
TrySchedule(ReaderScheduler, completionData);
@@ -355,7 +355,7 @@ namespace System.IO.Pipelines
return result;
}
- private void PrepareFlush(out CompletionData completionData, out ValueTask<FlushResult> result, CancellationToken cancellationToken)
+ private void PrepareFlushUnsynchronized(out CompletionData completionData, out ValueTask<FlushResult> result, CancellationToken cancellationToken)
{
var completeReader = CommitUnsynchronized();
@@ -691,6 +691,9 @@ namespace System.IO.Pipelines
// We also need to flip the reading state off
_operationState.EndRead();
+
+ // Begin read again to wire up cancellation token
+ _readerAwaitable.BeginOperation(token, s_signalReaderAwaitable, this);
}
// If the writer is currently paused and we are about the wait for more data then this would deadlock.
@@ -1057,7 +1060,7 @@ namespace System.IO.Pipelines
WriteMultiSegment(source.Span);
}
- PrepareFlush(out completionData, out result, cancellationToken);
+ PrepareFlushUnsynchronized(out completionData, out result, cancellationToken);
}
TrySchedule(ReaderScheduler, completionData);
diff --git a/src/libraries/System.IO.Pipelines/tests/PipeReaderReadAtLeastAsyncTests.cs b/src/libraries/System.IO.Pipelines/tests/PipeReaderReadAtLeastAsyncTests.cs
index c12d3b88253..64762de5ec8 100644
--- a/src/libraries/System.IO.Pipelines/tests/PipeReaderReadAtLeastAsyncTests.cs
+++ b/src/libraries/System.IO.Pipelines/tests/PipeReaderReadAtLeastAsyncTests.cs
@@ -162,5 +162,36 @@ namespace System.IO.Pipelines.Tests
Assert.True(result.IsCanceled);
PipeReader.AdvanceTo(buffer.End);
}
+
+ [Fact]
+ public Task ReadAtLeastAsyncCancelableWhenWaitingForMoreData()
+ {
+ CancellationTokenSource cts = new CancellationTokenSource();
+ ValueTask<ReadResult> task = PipeReader.ReadAtLeastAsync(1, cts.Token);
+ cts.Cancel();
+ return Assert.ThrowsAsync<OperationCanceledException>(async () => await task);
+ }
+
+ [Fact]
+ public async Task ReadAtLeastAsyncCancelableAfterReadingSome()
+ {
+ CancellationTokenSource cts = new CancellationTokenSource();
+ await Pipe.WriteAsync(new byte[10], default);
+ ValueTask<ReadResult> task = PipeReader.ReadAtLeastAsync(11, cts.Token);
+ cts.Cancel();
+ await Assert.ThrowsAsync<OperationCanceledException>(async () => await task);
+ }
+
+ [Fact]
+ public async Task ReadAtLeastAsyncCancelableAfterReadingSomeAndWritingAfterStartingRead()
+ {
+ CancellationTokenSource cts = new CancellationTokenSource();
+ await Pipe.WriteAsync(new byte[10], default);
+ ValueTask<ReadResult> task = PipeReader.ReadAtLeastAsync(12, cts.Token);
+ // Write, but not enough to unblock ReadAtLeastAsync
+ await Pipe.WriteAsync(new byte[1], default);
+ cts.Cancel();
+ await Assert.ThrowsAnyAsync<OperationCanceledException>(async () => await task);
+ }
}
}
diff --git a/src/libraries/System.Text.Json/src/System.Text.Json.csproj b/src/libraries/System.Text.Json/src/System.Text.Json.csproj
index d88d2be69fe..3ee7607c9b1 100644
--- a/src/libraries/System.Text.Json/src/System.Text.Json.csproj
+++ b/src/libraries/System.Text.Json/src/System.Text.Json.csproj
@@ -9,7 +9,8 @@
<Nullable>enable</Nullable>
<IncludeInternalObsoleteAttribute>true</IncludeInternalObsoleteAttribute>
<IsPackable>true</IsPackable>
- <ServicingVersion>3</ServicingVersion>
+ <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
+ <ServicingVersion>4</ServicingVersion>
<PackageDescription>Provides high-performance and low-allocating types that serialize objects to JavaScript Object Notation (JSON) text and deserialize JSON text to objects, with UTF-8 support built-in. Also provides types to read and write JSON text encoded as UTF-8, and to create an in-memory document object model (DOM), that is read-only, for random access of the JSON elements within a structured view of the data.
Commonly Used Types:
diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.Converters.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.Converters.cs
index 77b5d7071f7..2563794dcc5 100644
--- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.Converters.cs
+++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.Converters.cs
@@ -10,6 +10,7 @@ using System.Text.Json.Reflection;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization.Converters;
using System.Text.Json.Serialization.Metadata;
+using System.Threading;
namespace System.Text.Json
{
@@ -30,10 +31,10 @@ namespace System.Text.Json
[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)]
private void RootBuiltInConverters()
{
- if (s_defaultSimpleConverters is null)
+ if (Volatile.Read(ref s_defaultFactoryConverters) is null)
{
s_defaultSimpleConverters = GetDefaultSimpleConverters();
- s_defaultFactoryConverters = new JsonConverter[]
+ Volatile.Write(ref s_defaultFactoryConverters, new JsonConverter[]
{
// Check for disallowed types.
new UnsupportedTypeConverterFactory(),
@@ -48,7 +49,7 @@ namespace System.Text.Json
new IEnumerableConverterFactory(),
// Object should always be last since it converts any type.
new ObjectConverterFactory()
- };
+ });
}
}