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

Merge common code bases for TdsParserStateObject.cs (5) #2302

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

panoskj
Copy link
Contributor

@panoskj panoskj commented Jan 18, 2024

This is a draft PR as I intend to add a few more commits. But let me know if you think this should be merged by itself.

So, in this comment, I asked about ValidateSNIConnection (3rd question, 4 possible solutions are suggested). @David-Engel responded and it looks like we both agree on the implementation of this PR.

To sum up, this PR effectively changes the implementation of IsConnectionAlive in netfx to check if the handle is null before passing it to SNICheckConnection. If it is null, the connection will be considered alive. This behavior is in line with netcore implementation for native.

Moreover, it appears that:

  1. Native SNICheckConnection doesn't expect null values.
  2. The handle in question will only be null if the TdsParserStateObject has been disposed.
  3. We assume IsConnectionAlive is not called if TdsParserStateObject has been disposed (otherwise you would have noticed the bug already).

Therefore, an even better implementation would be to throw an exception (or at least use a debug assertion) to make sure the handle is never null when CheckConnection is called. Note that netcore already does this for the managed implementation (which reinforces the assumption (3)). The null check below the linked line is redundant by the way (I guess the null check predated throwing the exception).

Let me know what you think @Wraith2 @DavoudEshtehari @JRahnama @David-Engel

…an exception: 1) there is no returned value and 2) the "error" variable is not used - there is no need to initialize it with SNI_SUCCESS.
Copy link

codecov bot commented Jan 18, 2024

Codecov Report

Attention: 35 lines in your changes are missing coverage. Please review.

Comparison is base (b12b15d) 72.57% compared to head (3354c9c) 66.67%.
Report is 1 commits behind head on main.

Files Patch % Lines
...c/Microsoft/Data/SqlClient/TdsParserStateObject.cs 86.28% 31 Missing ⚠️
...osoft/Data/SqlClient/TdsParserStateObject.netfx.cs 89.28% 3 Missing ⚠️
...oft/Data/SqlClient/TdsParserStateObject.netcore.cs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2302      +/-   ##
==========================================
- Coverage   72.57%   66.67%   -5.90%     
==========================================
  Files         310      304       -6     
  Lines       62065    61544     -521     
==========================================
- Hits        45041    41036    -4005     
- Misses      17024    20508    +3484     
Flag Coverage Δ
addons ∅ <ø> (∅)
netcore 70.84% <86.26%> (-5.89%) ⬇️
netfx 64.36% <86.97%> (-5.60%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant