Fix rare deadlock in TestHost

This commit is contained in:
BrennanConroy 2016-03-25 10:30:42 -07:00
parent a0de7564e2
commit 8451d1afcb
1 changed files with 8 additions and 0 deletions

View File

@ -352,6 +352,14 @@ namespace Microsoft.AspNetCore.TestHost
internal void Complete()
{
// If HttpClient.Dispose gets called while HttpClient.SetTask...() is called
// there is a chance that this method will be called twice and hang on the lock
// to prevent this we can check if there is already a thread inside the lock
if (_complete)
{
return;
}
// Prevent race with WaitForDataAsync
lock (_signalReadLock)
{