- Notifications
You must be signed in to change notification settings - Fork5.1k
avoid allocationg ApplicationProtocol in common case#69098
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
ghost commentedMay 10, 2022
Tagging subscribers to this area: @dotnet/ncl,@vcsjones Issue Detailscontributes to#68951
|
src/libraries/System.Net.Security/src/System/Net/Security/SslConnectionInfo.csShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/libraries/Common/src/Interop/Windows/SChannel/Interop.SecPkgContext_ApplicationProtocol.csShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
@@ -17,7 +17,20 @@ internal partial struct SslConnectionInfo | |||
alpnContext.ProtoNegoExt == Interop.ApplicationProtocolNegotiationExt.ALPN && | |||
alpnContext.ProtoNegoStatus == Interop.ApplicationProtocolNegotiationStatus.Success) | |||
{ | |||
return alpnContext.Protocol; | |||
if (alpnContext.ProtocolIdSize == s_http1.Length && alpnContext.Protocol.SequenceEqual(s_http1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Why does the Windows one check ProtocolIdSize but the Linux one doesn't?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The code originally looked different and I did not want to allocate the Span unless we need to. Perhaps that is cheap. Here I have the size available directly so I left the check in place. On Linux, The Interop function returns always Span so the code is somewhat different. I can remove the extra check if we want to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LGTM, modulo existing comments
contributes to#68951
For now, I updated Linux & Windows. Other platforms may be possible.