Skip to content

Commit f8e5978

Browse files
committed
use volatile for _headersTaskOrSource
1 parent 4c49678 commit f8e5978

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/protobuf-net.Grpc/Internal/MetadataContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ internal Metadata Headers
2727

2828
internal Task<Metadata>? GetHeadersTask(bool createIfMissing)
2929
{
30-
return _headersTaskOrSource switch
30+
return Volatile.Read(ref _headersTaskOrSource) switch
3131
{
3232
Task<Metadata> task => task,
3333
TaskCompletionSource<Metadata> tcs => tcs.Task,
@@ -60,7 +60,7 @@ internal MetadataContext Reset()
6060
{
6161
Status = Status.DefaultSuccess;
6262
_trailers = null;
63-
_headersTaskOrSource = null;
63+
Volatile.Write(ref _headersTaskOrSource, null);
6464
return this;
6565
}
6666

0 commit comments

Comments
 (0)