@@ -67,89 +67,7 @@ internal int ObjectID
67
67
/// Verify client encryption possibility.
68
68
/// </summary>
69
69
private bool ClientOSEncryptionSupport => SNILoadHandle.SingletonInstance.ClientOSEncryptionSupport;
70
-
71
- // ReliabilitySection Usage:
72
- //
73
- // #if DEBUG
74
- // TdsParser.ReliabilitySection tdsReliabilitySection = new TdsParser.ReliabilitySection();
75
- //
76
- // RuntimeHelpers.PrepareConstrainedRegions();
77
- // try {
78
- // tdsReliabilitySection.Start();
79
- // #else
80
- // {
81
- // #endif //DEBUG
82
- //
83
- // // code that requires reliability
84
- //
85
- // }
86
- // #if DEBUG
87
- // finally {
88
- // tdsReliabilitySection.Stop();
89
- // }
90
- // #endif //DEBUG
91
-
92
- internal struct ReliabilitySection
93
- {
94
- #if DEBUG
95
- // do not allocate TLS data in RETAIL bits
96
- [ThreadStatic]
97
- private static int s_reliabilityCount; // initialized to 0 by CLR
98
-
99
- private bool m_started; // initialized to false (not started) by CLR
100
- #endif //DEBUG
101
-
102
- [Conditional("DEBUG")]
103
- internal void Start()
104
- {
105
- #if DEBUG
106
- Debug.Assert(!m_started);
107
-
108
- RuntimeHelpers.PrepareConstrainedRegions();
109
- try
110
- {
111
- }
112
- finally
113
- {
114
- ++s_reliabilityCount;
115
- m_started = true;
116
- }
117
- #endif //DEBUG
118
- }
119
-
120
- [Conditional("DEBUG")]
121
- internal void Stop()
122
- {
123
- #if DEBUG
124
- // cannot assert m_started - ThreadAbortException can be raised before Start is called
125
-
126
- if (m_started)
127
- {
128
- Debug.Assert(s_reliabilityCount > 0);
129
-
130
- RuntimeHelpers.PrepareConstrainedRegions();
131
- try
132
- {
133
- }
134
- finally
135
- {
136
- --s_reliabilityCount;
137
- m_started = false;
138
- }
139
- }
140
- #endif //DEBUG
141
- }
142
-
143
- // you need to setup for a thread abort somewhere before you call this method
144
- [Conditional("DEBUG")]
145
- internal static void Assert(string message)
146
- {
147
- #if DEBUG
148
- Debug.Assert(s_reliabilityCount > 0, message);
149
- #endif //DEBUG
150
- }
151
- }
152
-
70
+
153
71
// Default state object for parser
154
72
internal TdsParserStateObject _physicalStateObj = null; // Default stateObj and connection for Dbnetlib and non-MARS SNI.
155
73
@@ -806,60 +724,6 @@ internal void Connect(ServerInfo serverInfo,
806
724
return;
807
725
}
808
726
809
- // Retrieve the IP and port number from native SNI for TCP protocol. The IP information is stored temporarily in the
810
- // pendingSQLDNSObject but not in the DNS Cache at this point. We only add items to the DNS Cache after we receive the
811
- // IsSupported flag as true in the feature ext ack from server.
812
- internal void AssignPendingDNSInfo(string userProtocol, string DNSCacheKey)
813
- {
814
- UInt32 result;
815
- ushort portFromSNI = 0;
816
- string IPStringFromSNI = string.Empty;
817
- IPAddress IPFromSNI;
818
- isTcpProtocol = false;
819
- Provider providerNumber = Provider.INVALID_PROV;
820
-
821
- if (string.IsNullOrEmpty(userProtocol))
822
- {
823
-
824
- result = SNINativeMethodWrapper.SniGetProviderNumber(_physicalStateObj.Handle, ref providerNumber);
825
- Debug.Assert(result == TdsEnums.SNI_SUCCESS, "Unexpected failure state upon calling SniGetProviderNumber");
826
- isTcpProtocol = (providerNumber == Provider.TCP_PROV);
827
- }
828
- else if (userProtocol == TdsEnums.TCP)
829
- {
830
- isTcpProtocol = true;
831
- }
832
-
833
- // serverInfo.UserProtocol could be empty
834
- if (isTcpProtocol)
835
- {
836
- result = SNINativeMethodWrapper.SniGetConnectionPort(_physicalStateObj.Handle, ref portFromSNI);
837
- Debug.Assert(result == TdsEnums.SNI_SUCCESS, "Unexpected failure state upon calling SniGetConnectionPort");
838
-
839
-
840
- result = SNINativeMethodWrapper.SniGetConnectionIPString(_physicalStateObj.Handle, ref IPStringFromSNI);
841
- Debug.Assert(result == TdsEnums.SNI_SUCCESS, "Unexpected failure state upon calling SniGetConnectionIPString");
842
-
843
- _connHandler.pendingSQLDNSObject = new SQLDNSInfo(DNSCacheKey, null, null, portFromSNI.ToString());
844
-
845
- if (IPAddress.TryParse(IPStringFromSNI, out IPFromSNI))
846
- {
847
- if (System.Net.Sockets.AddressFamily.InterNetwork == IPFromSNI.AddressFamily)
848
- {
849
- _connHandler.pendingSQLDNSObject.AddrIPv4 = IPStringFromSNI;
850
- }
851
- else if (System.Net.Sockets.AddressFamily.InterNetworkV6 == IPFromSNI.AddressFamily)
852
- {
853
- _connHandler.pendingSQLDNSObject.AddrIPv6 = IPStringFromSNI;
854
- }
855
- }
856
- }
857
- else
858
- {
859
- _connHandler.pendingSQLDNSObject = null;
860
- }
861
- }
862
-
863
727
internal void RemoveEncryption()
864
728
{
865
729
Debug.Assert((_encryptionOption & EncryptionOptions.OPTIONS_MASK) == EncryptionOptions.LOGIN, "Invalid encryption option state");
@@ -990,41 +854,6 @@ internal void PutSession(TdsParserStateObject session)
990
854
}
991
855
}
992
856
993
- // This is called from a ThreadAbort - ensure that it can be run from a CER Catch
994
- internal void BestEffortCleanup()
995
- {
996
- _state = TdsParserState.Broken;
997
-
998
- var stateObj = _physicalStateObj;
999
- if (stateObj != null)
1000
- {
1001
- var stateObjHandle = stateObj.Handle;
1002
- if (stateObjHandle != null)
1003
- {
1004
- stateObjHandle.Dispose();
1005
- }
1006
- }
1007
-
1008
- if (_fMARS)
1009
- {
1010
- var sessionPool = _sessionPool;
1011
- if (sessionPool != null)
1012
- {
1013
- sessionPool.BestEffortCleanup();
1014
- }
1015
-
1016
- var marsStateObj = _pMarsPhysicalConObj;
1017
- if (marsStateObj != null)
1018
- {
1019
- var marsStateObjHandle = marsStateObj.Handle;
1020
- if (marsStateObjHandle != null)
1021
- {
1022
- marsStateObjHandle.Dispose();
1023
- }
1024
- }
1025
- }
1026
- }
1027
-
1028
857
private void SendPreLoginHandshake(
1029
858
byte[] instanceName,
1030
859
SqlConnectionEncryptOption encrypt,
@@ -2249,44 +2078,6 @@ internal void PrepareResetConnection(bool preserveTransaction)
2249
2078
_fPreserveTransaction = preserveTransaction;
2250
2079
}
2251
2080
2252
- internal bool RunReliably(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
2253
- {
2254
- RuntimeHelpers.PrepareConstrainedRegions();
2255
- try
2256
- {
2257
- #if DEBUG
2258
- TdsParser.ReliabilitySection tdsReliabilitySection = new TdsParser.ReliabilitySection();
2259
- RuntimeHelpers.PrepareConstrainedRegions();
2260
- try
2261
- {
2262
- tdsReliabilitySection.Start();
2263
- #endif //DEBUG
2264
- return Run(runBehavior, cmdHandler, dataStream, bulkCopyHandler, stateObj);
2265
- #if DEBUG
2266
- }
2267
- finally
2268
- {
2269
- tdsReliabilitySection.Stop();
2270
- }
2271
- #endif //DEBUG
2272
- }
2273
- catch (OutOfMemoryException)
2274
- {
2275
- _connHandler.DoomThisConnection();
2276
- throw;
2277
- }
2278
- catch (StackOverflowException)
2279
- {
2280
- _connHandler.DoomThisConnection();
2281
- throw;
2282
- }
2283
- catch (ThreadAbortException)
2284
- {
2285
- _connHandler.DoomThisConnection();
2286
- throw;
2287
- }
2288
- }
2289
-
2290
2081
internal bool Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
2291
2082
{
2292
2083
bool syncOverAsync = stateObj._syncOverAsync;
0 commit comments