Skip to content

Commit f824db7

Browse files
committed
Move CreateConsumerInfo and _gcHandle to TdsParserStateObjectNative
1 parent 1e4724e commit f824db7

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserStateObject.netfx.cs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ internal partial class TdsParserStateObject
2626
protected SNIPacket _sniPacket = null; // Will have to re-vamp this for MARS
2727
internal SNIPacket _sniAsyncAttnPacket = null; // Packet to use to send Attn
2828

29-
// Async variables
30-
protected GCHandle _gcHandle; // keeps this object alive until we're closed.
31-
3229
// Used for blanking out password in trace.
3330
internal int _tracePasswordOffset = 0;
3431
internal int _tracePasswordLength = 0;
@@ -86,24 +83,6 @@ internal SNIHandle Handle
8683
// General methods //
8784
/////////////////////
8885

89-
protected ConsumerInfo CreateConsumerInfo(bool async)
90-
{
91-
ConsumerInfo myInfo = new ConsumerInfo();
92-
93-
Debug.Assert(_outBuff.Length == _inBuff.Length, "Unexpected unequal buffers.");
94-
95-
myInfo.defaultBufferSize = _outBuff.Length; // Obtain packet size from outBuff size.
96-
97-
if (async)
98-
{
99-
myInfo.readDelegate = SNILoadHandle.SingletonInstance.ReadAsyncCallbackDispatcher;
100-
myInfo.writeDelegate = SNILoadHandle.SingletonInstance.WriteAsyncCallbackDispatcher;
101-
_gcHandle = GCHandle.Alloc(this, GCHandleType.Normal);
102-
myInfo.key = (IntPtr)_gcHandle;
103-
}
104-
return myInfo;
105-
}
106-
10786
internal uint CheckConnection() => SniNativeWrapper.SniCheckConnection(Handle);
10887

10988
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserStateObjectNative.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ internal class TdsParserStateObjectNative : TdsParserStateObject
2020
{
2121
private readonly WritePacketCache _writePacketCache = new WritePacketCache(); // Store write packets that are ready to be re-used
2222

23+
private GCHandle _gcHandle; // keeps this object alive until we're closed.
24+
2325
private readonly Dictionary<IntPtr, SNIPacket> _pendingWritePackets = new Dictionary<IntPtr, SNIPacket>(); // Stores write packets that have been sent to SNI, but have not yet finished writing (i.e. we are waiting for SNI's callback)
2426

2527
internal TdsParserStateObjectNative(TdsParser parser, TdsParserStateObject physicalConnection, bool async)
@@ -109,6 +111,24 @@ internal override void AssignPendingDNSInfo(string userProtocol, string DNSCache
109111
}
110112
}
111113

114+
private ConsumerInfo CreateConsumerInfo(bool async)
115+
{
116+
ConsumerInfo myInfo = new ConsumerInfo();
117+
118+
Debug.Assert(_outBuff.Length == _inBuff.Length, "Unexpected unequal buffers.");
119+
120+
myInfo.defaultBufferSize = _outBuff.Length; // Obtain packet size from outBuff size.
121+
122+
if (async)
123+
{
124+
myInfo.readDelegate = SNILoadHandle.SingletonInstance.ReadAsyncCallbackDispatcher;
125+
myInfo.writeDelegate = SNILoadHandle.SingletonInstance.WriteAsyncCallbackDispatcher;
126+
_gcHandle = GCHandle.Alloc(this, GCHandleType.Normal);
127+
myInfo.key = (IntPtr)_gcHandle;
128+
}
129+
return myInfo;
130+
}
131+
112132
internal override void CreatePhysicalSNIHandle(
113133
string serverName,
114134
TimeoutTimer timeout,

0 commit comments

Comments
 (0)