Skip to content

Commit 469d840

Browse files
committed
Merge CreateSessionHandle
1 parent 7daf3ab commit 469d840

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ internal static void PrepareConstrainedRegions()
3131
// Constructors //
3232
//////////////////
3333

34-
internal TdsParserStateObject(TdsParser parser, TdsParserStateObject physicalConnection, bool async)
34+
protected TdsParserStateObject(TdsParser parser, TdsParserStateObject physicalConnection, bool async)
3535
{
3636
// Construct a MARS session
3737
Debug.Assert(parser != null, "no parser?");
@@ -86,8 +86,6 @@ internal abstract void CreatePhysicalSNIHandle(
8686

8787
internal abstract void AssignPendingDNSInfo(string userProtocol, string DNSCacheKey, ref SQLDNSInfo pendingDNSInfo);
8888

89-
protected abstract void CreateSessionHandle(TdsParserStateObject physicalConnection, bool async);
90-
9189
protected abstract void FreeGcHandle(int remaining, bool release);
9290

9391
internal abstract uint EnableSsl(ref uint info, bool tlsFirst, string serverCertificateFilename);

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ internal partial class TdsParserStateObject
3939
// Constructors //
4040
//////////////////
4141

42-
protected TdsParserStateObject(TdsParser parser, SNIHandle physicalConnection, bool async)
42+
protected TdsParserStateObject(TdsParser parser, TdsParserStateObject physicalConnection, bool async)
4343
{
4444
// Construct a MARS session
4545
Debug.Assert(parser != null, "no parser?");
@@ -56,12 +56,8 @@ protected TdsParserStateObject(TdsParser parser, SNIHandle physicalConnection, b
5656
// Determine packet size based on physical connection buffer lengths.
5757
SetPacketSize(_parser._physicalStateObj._outBuff.Length);
5858

59-
ConsumerInfo myInfo = CreateConsumerInfo(async);
60-
SQLDNSInfo cachedDNSInfo;
61-
62-
SQLFallbackDNSCache.Instance.GetDNSInfo(_parser.FQDNforDNSCache, out cachedDNSInfo);
59+
CreateSessionHandle(physicalConnection, async);
6360

64-
_sessionHandle = new SNIHandle(myInfo, physicalConnection, _parser.Connection.ConnectionOptions.IPAddressPreference, cachedDNSInfo);
6561
if (IsFailedHandle())
6662
{
6763
AddError(parser.ProcessSNIError(this));
@@ -90,7 +86,7 @@ internal SNIHandle Handle
9086
// General methods //
9187
/////////////////////
9288

93-
private ConsumerInfo CreateConsumerInfo(bool async)
89+
protected ConsumerInfo CreateConsumerInfo(bool async)
9490
{
9591
ConsumerInfo myInfo = new ConsumerInfo();
9692

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ internal class TdsParserStateObjectNative : TdsParserStateObject
1919
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)
2020

2121
internal TdsParserStateObjectNative(TdsParser parser, TdsParserStateObject physicalConnection, bool async)
22-
: base(parser, physicalConnection.Handle, async)
22+
: base(parser, physicalConnection, async)
2323
{
2424
}
2525

@@ -40,6 +40,18 @@ public TdsParserStateObjectNative(TdsParser parser)
4040

4141
internal override Guid? SessionId => default;
4242

43+
protected override void CreateSessionHandle(TdsParserStateObject physicalConnection, bool async)
44+
{
45+
Debug.Assert(physicalConnection is TdsParserStateObjectNative, "Expected a stateObject of type " + this.GetType());
46+
TdsParserStateObjectNative nativeSNIObject = physicalConnection as TdsParserStateObjectNative;
47+
ConsumerInfo myInfo = CreateConsumerInfo(async);
48+
49+
SQLDNSInfo cachedDNSInfo;
50+
bool ret = SQLFallbackDNSCache.Instance.GetDNSInfo(_parser.FQDNforDNSCache, out cachedDNSInfo);
51+
52+
_sessionHandle = new SNIHandle(myInfo, nativeSNIObject.Handle, _parser.Connection.ConnectionOptions.IPAddressPreference, cachedDNSInfo);
53+
}
54+
4355
protected override uint SniPacketGetData(PacketHandle packet, byte[] _inBuff, ref uint dataSize)
4456
{
4557
Debug.Assert(packet.Type == PacketHandle.NativePointerType, "unexpected packet type when requiring NativePointer");

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,8 @@ internal long TimeoutTime
483483

484484
protected abstract PacketHandle EmptyReadPacket { get; }
485485

486+
protected abstract void CreateSessionHandle(TdsParserStateObject physicalConnection, bool async);
487+
486488
internal abstract PacketHandle GetResetWritePacket(int dataSize);
487489

488490
protected abstract uint SniPacketGetData(PacketHandle packet, byte[] _inBuff, ref uint dataSize);

0 commit comments

Comments
 (0)