Fix flaky disconnect test (#1533)
This commit is contained in:
parent
55d849a0d0
commit
293d165a80
|
|
@ -184,11 +184,11 @@ namespace Microsoft.AspNetCore.Server.IIS.Core
|
|||
}
|
||||
}
|
||||
|
||||
private void AbortIO()
|
||||
private bool AbortIO()
|
||||
{
|
||||
if (Interlocked.CompareExchange(ref _requestAborted, 1, 0) != 0)
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
_bodyOutput.Dispose();
|
||||
|
|
@ -208,6 +208,8 @@ namespace Microsoft.AspNetCore.Server.IIS.Core
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Abort(Exception reason)
|
||||
|
|
@ -221,8 +223,10 @@ namespace Microsoft.AspNetCore.Server.IIS.Core
|
|||
|
||||
internal void ConnectionReset()
|
||||
{
|
||||
AbortIO();
|
||||
Log.ConnectionDisconnect(_logger, ((IHttpConnectionFeature)this).ConnectionId);
|
||||
if (AbortIO())
|
||||
{
|
||||
Log.ConnectionDisconnect(_logger, ((IHttpConnectionFeature)this).ConnectionId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,9 @@ namespace Microsoft.AspNetCore.Server.IIS.Core.IO
|
|||
{
|
||||
if (_stopped)
|
||||
{
|
||||
throw new IOException("IO stopped", NativeMethods.ERROR_OPERATION_ABORTED);
|
||||
// Abort all operation after IO was stopped
|
||||
ioOperation.Complete(NativeMethods.ERROR_OPERATION_ABORTED, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_runningOperation != null)
|
||||
|
|
|
|||
|
|
@ -2,13 +2,11 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Connections;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||
using Microsoft.AspNetCore.Testing.xunit;
|
||||
using Microsoft.Extensions.Logging.Testing;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
||||
|
|
@ -207,8 +205,6 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
}
|
||||
Assert.IsType<OperationCanceledException>(exception);
|
||||
}
|
||||
|
||||
AssertConnectionDisconnectLog();
|
||||
}
|
||||
|
||||
[ConditionalFact]
|
||||
|
|
@ -289,7 +285,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
|
||||
private void AssertConnectionDisconnectLog()
|
||||
{
|
||||
Assert.Contains(TestSink.Writes, w => w.EventId.Name == "ConnectionDisconnect");
|
||||
Assert.Single(TestSink.Writes, w => w.EventId.Name == "ConnectionDisconnect");
|
||||
}
|
||||
|
||||
private static async Task SendContentLength1Post(TestConnection connection)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
{
|
||||
[SkipIfHostableWebCoreNotAvailable]
|
||||
[OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, "https://github.com/aspnet/IISIntegration/issues/866")]
|
||||
public class TestServerTest : LoggedTest
|
||||
public class TestServerTest : StrictTestServerTests
|
||||
{
|
||||
[ConditionalFact]
|
||||
public async Task SingleProcessTestServer_HelloWorld()
|
||||
|
|
|
|||
Loading…
Reference in New Issue