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

Commit ea703b8

Browse files
Merge pull request #2534 from khellang/prevent-deadlock
Remove Wait call to prevent deadlock
2 parents 36b1396 + 0cf8c58 commit ea703b8

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

src/Nancy/IO/RequestStream.cs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
{
33
using System;
44
using System.IO;
5-
using System.Threading.Tasks;
6-
7-
using Nancy.Extensions;
85

96
/// <summary>
107
/// A <see cref="Stream"/> decorator that can handle moving the stream out from memory and on to disk when the contents reaches a certain length.
@@ -74,15 +71,7 @@ public RequestStream(Stream stream, long expectedLength, long thresholdLength, b
7471

7572
if (!this.stream.CanSeek)
7673
{
77-
var task =
78-
MoveToWritableStream();
79-
80-
task.Wait();
81-
82-
if (task.IsFaulted)
83-
{
84-
throw new InvalidOperationException("Unable to copy stream", task.Exception);
85-
}
74+
this.MoveToWritableStream();
8675
}
8776

8877
this.stream.Position = 0;
@@ -93,12 +82,13 @@ public RequestStream(Stream stream, long expectedLength, long thresholdLength, b
9382
this.Dispose(false);
9483
}
9584

96-
private Task MoveToWritableStream()
85+
private void MoveToWritableStream()
9786
{
9887
var sourceStream = this.stream;
88+
9989
this.stream = new MemoryStream(BufferSize);
10090

101-
return sourceStream.CopyToAsync(this);
91+
sourceStream.CopyTo(this.stream);
10292
}
10393

10494
/// <summary>

0 commit comments

Comments
 (0)