Skip to content
This repository was archived by the owner on Jan 24, 2021. It is now read-only.

Commit 88f985f

Browse files
davidyoung-cmdkhellang
authored andcommitted
- Removed wait call from the RequestStream to prevent a potential deadlock.
1 parent 9e3b038 commit 88f985f

1 file changed

Lines changed: 3 additions & 11 deletions

File tree

src/Nancy/IO/RequestStream.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,7 @@ public RequestStream(Stream stream, long expectedLength, long thresholdLength, b
8181

8282
if (!this.stream.CanSeek)
8383
{
84-
var task =
85-
MoveToWritableStream();
86-
87-
task.Wait();
88-
89-
if (task.IsFaulted)
90-
{
91-
throw new InvalidOperationException("Unable to copy stream", task.Exception);
92-
}
84+
this.MoveToWritableStream();
9385
}
9486

9587
this.stream.Position = 0;
@@ -103,12 +95,12 @@ public RequestStream(Stream stream, long expectedLength, long thresholdLength, b
10395
this.Dispose(false);
10496
}
10597

106-
private Task MoveToWritableStream()
98+
private void MoveToWritableStream()
10799
{
108100
var sourceStream = this.stream;
109101
this.stream = new MemoryStream(BufferSize);
110102

111-
return sourceStream.CopyToAsync(this);
103+
sourceStream.CopyTo(this.stream);
112104
}
113105

114106
/// <summary>

0 commit comments

Comments
 (0)