Skip to content

Don't call HttpCloseUrlGroup if you didn't create it #28336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions src/Servers/HttpSys/src/NativeInterop/UrlGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ internal class UrlGroup : IDisposable

private ServerSession _serverSession;
private bool _disposed;
private bool _created;

internal unsafe UrlGroup(ServerSession serverSession, ILogger logger)
{
_serverSession = serverSession;
_logger = logger;

ulong urlGroupId = 0;
_created = true;
var statusCode = HttpApi.HttpCreateUrlGroup(
_serverSession.Id.DangerousGetServerSessionId(), &urlGroupId, 0);

Expand All @@ -44,6 +46,7 @@ internal unsafe UrlGroup(RequestQueue requestQueue, UrlPrefix url, ILogger logge
_logger = logger;

ulong urlGroupId = 0;
_created = false;
var statusCode = HttpApi.HttpFindUrlGroupId(
url.FullPrefix, requestQueue.Handle, &urlGroupId);

Expand Down Expand Up @@ -141,14 +144,20 @@ public void Dispose()

_disposed = true;

Debug.Assert(Id != 0, "HttpCloseUrlGroup called with invalid url group id");
if (_created)
{

uint statusCode = HttpApi.HttpCloseUrlGroup(Id);
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);
}

if (statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS)
{
_logger.LogError(LoggerEventIds.CloseUrlGroupError, "HttpCloseUrlGroup; Result: {0}" , statusCode);
}

Id = 0;
}

Expand Down