Skip to content

Commit

Permalink
mitigation for quic tests hangs (dotnet#55985)
Browse files Browse the repository at this point in the history
  • Loading branch information
wfurt authored Jul 20, 2021
1 parent 6b09e32 commit 0a5e93b
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,9 @@ internal override int Read(Span<byte> buffer)
byte[] rentedBuffer = ArrayPool<byte>.Shared.Rent(buffer.Length);
try
{
int readLength = ReadAsync(new Memory<byte>(rentedBuffer, 0, buffer.Length)).AsTask().GetAwaiter().GetResult();
Task<int> t = ReadAsync(new Memory<byte>(rentedBuffer, 0, buffer.Length)).AsTask();
((IAsyncResult)t).AsyncWaitHandle.WaitOne();
int readLength = t.GetAwaiter().GetResult();
rentedBuffer.AsSpan(0, readLength).CopyTo(buffer);
return readLength;
}
Expand All @@ -666,7 +668,9 @@ internal override void Write(ReadOnlySpan<byte> buffer)
ThrowIfDisposed();

// TODO: optimize this.
WriteAsync(buffer.ToArray()).AsTask().GetAwaiter().GetResult();
Task t = WriteAsync(buffer.ToArray()).AsTask();
((IAsyncResult)t).AsyncWaitHandle.WaitOne();
t.GetAwaiter().GetResult();
}

// MsQuic doesn't support explicit flushing
Expand Down

0 comments on commit 0a5e93b

Please sign in to comment.