Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ namespace Microsoft.Data.SqlClient
{
internal partial class TdsParserStateObject
{
protected SNIHandle _sessionHandle = null; // the SNI handle we're to work on

// SNI variables // multiple resultsets in one batch.
protected SNIPacket _sniPacket = null; // Will have to re-vamp this for MARS
internal SNIPacket _sniAsyncAttnPacket = null; // Packet to use to send Attn

// Used for blanking out password in trace.
internal int _tracePasswordOffset = 0;
internal int _tracePasswordLength = 0;
Expand Down Expand Up @@ -68,17 +62,6 @@ protected TdsParserStateObject(TdsParser parser, TdsParserStateObject physicalCo
_lastSuccessfulIOTimer = parser._physicalStateObj._lastSuccessfulIOTimer;
}

////////////////
// Properties //
////////////////
internal SNIHandle Handle
{
get
{
return _sessionHandle;
}
}

/////////////////////
// General methods //
/////////////////////
Expand All @@ -92,7 +75,7 @@ internal int DecrementPendingCallbacks(bool release)

// NOTE: TdsParserSessionPool may call DecrementPendingCallbacks on a TdsParserStateObject which is already disposed
// This is not dangerous (since the stateObj is no longer in use), but we need to add a workaround in the assert for it
Debug.Assert((remaining == -1 && _sessionHandle == null) || (0 <= remaining && remaining < 3), $"_pendingCallbacks values is invalid after decrementing: {remaining}");
Debug.Assert((remaining == -1 && SessionHandle.IsNull) || (0 <= remaining && remaining < 3), $"_pendingCallbacks values is invalid after decrementing: {remaining}");
return remaining;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ namespace Microsoft.Data.SqlClient
{
internal class TdsParserStateObjectNative : TdsParserStateObject
{
private SNIHandle _sessionHandle = null; // the SNI handle we're to work on

private SNIPacket _sniPacket = null; // Will have to re-vamp this for MARS
internal SNIPacket _sniAsyncAttnPacket = null; // Packet to use to send Attn
private readonly WritePacketCache _writePacketCache = new WritePacketCache(); // Store write packets that are ready to be re-used

private GCHandle _gcHandle; // keeps this object alive until we're closed.
Expand All @@ -37,6 +41,8 @@ internal TdsParserStateObjectNative(TdsParser parser)

#region Properties

internal SNIHandle Handle => _sessionHandle;

internal override uint Status => _sessionHandle != null ? _sessionHandle.Status : TdsEnums.SNI_UNINITIALIZED;

internal override SessionHandle SessionHandle => SessionHandle.FromNativeHandle(_sessionHandle);
Expand Down