Skip to content
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

Improve diagnostics when allocating MsQuicApi #74985

Closed
wants to merge 1 commit into from

Conversation

rzikm
Copy link
Member

@rzikm rzikm commented Sep 2, 2022

This PR improves diagnostics when allocating MsQuicApi instance, this was useful when investigating #74952 and would be nice to get into .NET 7 as part of #74931.

@ghost
Copy link

ghost commented Sep 2, 2022

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

This PR improves diagnostics when allocating MsQuicApi instance, this was useful when investigating #74952 and would be nice to get into .NET 7 as part of #74931.

Author: rzikm
Assignees: rzikm
Labels:

area-System.Net.Http

Milestone: -

@rzikm rzikm changed the title Msquic-api-improve-diagnostics Improve diagnostics when allocating MsQuicApi Sep 2, 2022
@rzikm rzikm requested a review from a team September 2, 2022 09:00
@rzikm rzikm force-pushed the msquic-api-improve-diagnostics branch from a00ca20 to 7cf6eba Compare September 2, 2022 10:07
{
return new MsQuicApi(apiTable);
}

ThrowHelper.ThrowIfMsQuicError(openStatus);

// this should unreachable as TryOpenMsQuic returns non-success status on failure
throw new Exception("Failed to create MsQuicApi instance");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you were to invert this condition, you wouldn't need the unreachable throw:

if (!TryLoadMsQuic(out IntPtr msQuicHandle) || !TryOpenMsQuic(msQuicHandle, out QUIC_API_TABLE* apiTable, out openStatus))
{
    ThrowHelper.ThrowIfMsQuicError(openStatus);
}

return new MsQuicApi(apiTable);

You could also have a ThrowMsQuicError that was unconditional. Or just use throw GetExceptionForMsQuicStatus(openStatus);.

@rzikm
Copy link
Member Author

rzikm commented Sep 7, 2022

Since the change this follows up on was reverted, I am closing this issue, we can pick these changes in #75163 and have them in 1 commit for eventual porting

@ghost ghost locked as resolved and limited conversation to collaborators Oct 7, 2022
@karelz karelz added this to the 8.0.0 milestone Mar 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants