This commit is contained in:
Pavel Krymets 2018-07-06 11:36:51 -07:00
parent b280597c68
commit 5f02de1e2c
3 changed files with 42 additions and 6 deletions

View File

@ -187,12 +187,6 @@ APPLICATION_INFO::EnsureApplicationCreated(
// one optimization for failure scenario is to reduce the lock scope
SRWExclusiveLock lock(m_srwLock);
if (m_fDoneAppCreation)
{
// application is NULL and CreateApplication failed previously
FINISHED(E_APPLICATION_ACTIVATION_EXEC_FAILURE);
}
else
{
if (m_pApplication != NULL)
{

View File

@ -1,6 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.AspNetCore.Testing.xunit;
@ -38,5 +40,29 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{
Assert.DoesNotContain(@"\\?\", await _fixture.Client.GetStringAsync("/BasePath"));
}
[ConditionalFact]
public async Task GetServerVariableDoesNotCrash()
{
async Task RunRequests()
{
var client = new HttpClient() { BaseAddress = _fixture.Client.BaseAddress };
for (int j = 0; j < 10; j++)
{
var response = await client.GetStringAsync("/GetServerVariableStress");
Assert.StartsWith("Response Begin", response);
Assert.EndsWith("Response End", response);
}
}
List<Task> tasks = new List<Task>();
for (int i = 0; i < 10; i++)
{
tasks.Add(Task.Run(RunRequests));
}
await Task.WhenAll(tasks);
}
}
}

View File

@ -738,5 +738,21 @@ namespace IISTestSite
ctx.RequestServices.GetService<IApplicationLifetime>().StopApplication();
});
}
private async Task GetServerVariableStress(HttpContext context)
{
// This test simulates the scenario where native Flush call is being
// executed on background thread while request thread calls GetServerVariable
// concurrent native calls may cause native object corruption
await context.Response.WriteAsync("Response Begin");
for (int i = 0; i < 1000; i++)
{
await context.Response.WriteAsync(context.GetIISServerVariable("REMOTE_PORT"));
await context.Response.Body.FlushAsync();
}
await context.Response.WriteAsync("Response End");
}
}
}