- Notifications
You must be signed in to change notification settings - Fork311
Add partial packet detection and fixup#2714
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.
Changes from1 commit
94b6808
53c1139
3622f9c
d0fd956
25f0c62
cc694b9
fb9be3b
7f262eb
67b7762
57c8b86
b00a379
352ac25
51137f9
17ad988
eae759a
29ad90b
5d3f8a6
36cdd88
433ccf7
c65da55
b4460ec
80cbb6e
bb4fa9e
79f9fbc
d31e908
429b7ac
11dd84e
7684861
cd1e025
3ed9c83
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
…cess sni.
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -17,6 +17,12 @@ partial class TdsParserStateObject | ||
public void ProcessSniPacket(PacketHandle packet, uint error) | ||
{ | ||
if (LocalAppContextSwitches.UseCompatibilityProcessSni) | ||
{ | ||
ProcessSniPacketCompat(packet, error); | ||
return; | ||
} | ||
if (error != 0) | ||
{ | ||
if ((_parser.State == TdsParserState.Closed) || (_parser.State == TdsParserState.Broken)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Consider There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. This falls into the category of maintaining consistent style. The change wouldn't improve functionality and would leave us with files in the solution using different syntax to do the same thing which can cause you not to be able to find them or have to mentally determine that both syntaxes mean the same thing. If we're going to make this change I'd rather do it in a dedicated style update PR. I don't object to the new syntax I just think we should be consistent. | ||
@@ -488,5 +494,66 @@ private static bool SetupRemainderPacket(Packet packet) | ||
return containsFullPacket; | ||
} | ||
public void ProcessSniPacketCompat(PacketHandle packet, uint error) | ||
{ | ||
if (error != 0) | ||
{ | ||
if ((_parser.State == TdsParserState.Closed) || (_parser.State == TdsParserState.Broken)) | ||
{ | ||
// Do nothing with callback if closed or broken and error not 0 - callback can occur | ||
// after connection has been closed. PROBLEM IN NETLIB - DESIGN FLAW. | ||
return; | ||
} | ||
AddError(_parser.ProcessSNIError(this)); | ||
AssertValidState(); | ||
} | ||
else | ||
{ | ||
uint dataSize = 0; | ||
uint getDataError = | ||
#if NETFRAMEWORK | ||
SniNativeWrapper. | ||
#endif | ||
SNIPacketGetData(packet, _inBuff, ref dataSize); | ||
if (getDataError == TdsEnums.SNI_SUCCESS) | ||
{ | ||
if (_inBuff.Length < dataSize) | ||
{ | ||
Debug.Assert(true, "Unexpected dataSize on Read"); | ||
throw SQL.InvalidInternalPacketSize(StringsHelper.GetString(Strings.SqlMisc_InvalidArraySizeMessage)); | ||
} | ||
_lastSuccessfulIOTimer._value = DateTime.UtcNow.Ticks; | ||
_inBytesRead = (int)dataSize; | ||
_inBytesUsed = 0; | ||
if (_snapshot != null) | ||
{ | ||
_snapshot.AppendPacketData(_inBuff, _inBytesRead); | ||
if (_snapshotStatus != SnapshotStatus.NotActive) | ||
{ | ||
_snapshot.MoveNext(); | ||
#if DEBUG | ||
_snapshot.AssertCurrent(); | ||
#endif | ||
} | ||
} | ||
SniReadStatisticsAndTracing(); | ||
SqlClientEventSource.Log.TryAdvancedTraceBinEvent("TdsParser.ReadNetworkPacketAsyncCallback | INFO | ADV | State Object Id {0}, Packet read. In Buffer: {1}, In Bytes Read: {2}", ObjectID, _inBuff, _inBytesRead); | ||
AssertValidState(); | ||
} | ||
else | ||
{ | ||
throw SQL.ParsingError(ParsingErrorState.ProcessSniPacketFailed); | ||
} | ||
} | ||
} | ||
} | ||
} |