[release/5.0] Don't call HttpCloseUrlGroup if you didn't create it (#28511)

* Add created bool

* Be explicit in setting the flag
This commit is contained in:
Sourabh Shirhatti 2020-12-09 12:59:53 -08:00 committed by GitHub
parent 78d44383c8
commit 9654539fe7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 6 deletions

View File

@ -19,6 +19,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
private ServerSession _serverSession;
private ILogger _logger;
private bool _disposed;
private bool _created;
internal unsafe UrlGroup(ServerSession serverSession, ILogger logger)
{
@ -26,6 +27,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
_logger = logger;
ulong urlGroupId = 0;
_created = true;
var statusCode = HttpApi.HttpCreateUrlGroup(
_serverSession.Id.DangerousGetServerSessionId(), &urlGroupId, 0);
@ -41,6 +43,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
internal unsafe UrlGroup(RequestQueue requestQueue, UrlPrefix url)
{
ulong urlGroupId = 0;
_created = false;
var statusCode = HttpApi.HttpFindUrlGroupId(
url.FullPrefix, requestQueue.Handle, &urlGroupId);
@ -138,14 +141,20 @@ namespace Microsoft.AspNetCore.Server.HttpSys
_disposed = true;
Debug.Assert(Id != 0, "HttpCloseUrlGroup called with invalid url group id");
uint statusCode = HttpApi.HttpCloseUrlGroup(Id);
if (statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS)
if (_created)
{
_logger.LogError(LoggerEventIds.CloseUrlGroupError, "HttpCloseUrlGroup; Result: {0}" , statusCode);
Debug.Assert(Id != 0, "HttpCloseUrlGroup called with invalid url group id");
uint statusCode = HttpApi.HttpCloseUrlGroup(Id);
if (statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS)
{
_logger.LogError(LoggerEventIds.CloseUrlGroupError, "HttpCloseUrlGroup; Result: {0}", statusCode);
}
}
Id = 0;
}