Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
Removed SNIMarsManager, and modified TdsParserStateObjectManaged so t…
Browse files Browse the repository at this point in the history
…hat it manages its own SNIMarsConnection if MARS is enabled. This prevents SNIMarsConnections from accumulating forever in a static SNIMarsManager singleton. (#22709) (#23357)
  • Loading branch information
corivera authored and danmoseley committed Aug 17, 2017
1 parent c5fd47e commit 8d7ff69
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 92 deletions.
1 change: 0 additions & 1 deletion src/System.Data.SqlClient/src/System.Data.SqlClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@
<Compile Include="System\Data\SqlClient\SNI\SNILoadHandle.cs" />
<Compile Include="System\Data\SqlClient\SNI\SNIMarsConnection.cs" />
<Compile Include="System\Data\SqlClient\SNI\SNIMarsHandle.cs" />
<Compile Include="System\Data\SqlClient\SNI\SNIMarsManager.cs" />
<Compile Include="System\Data\SqlClient\SNI\SNIMarsQueuedPacket.cs" />
<Compile Include="System\Data\SqlClient\SNI\SNINpHandle.cs" />
<Compile Include="System\Data\SqlClient\SNI\SNIPacket.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public SNIMarsConnection(SNIHandle lowerHandle)
_lowerHandle.SetAsyncCallbacks(HandleReceiveComplete, HandleSendComplete);
}

public SNIMarsHandle CreateSession(object callbackObject, bool async)
public SNIMarsHandle CreateMarsSession(object callbackObject, bool async)
{
lock (this)
{
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,6 @@ public void Terminate()
{
}

/// <summary>
/// Enable MARS support on a connection
/// </summary>
/// <param name="handle">Connection handle</param>
/// <returns>SNI error code</returns>
public uint EnableMars(SNIHandle handle)
{
if (SNIMarsManager.Singleton.CreateMarsConnection(handle) == TdsEnums.SNI_SUCCESS_IO_PENDING)
{
return TdsEnums.SNI_SUCCESS;
}

return TdsEnums.SNI_ERROR;
}

/// <summary>
/// Enable SSL on a connection
/// </summary>
Expand Down Expand Up @@ -432,20 +417,6 @@ private SNINpHandle CreateNpHandle(DataSource details, long timerExpire, object
return new SNINpHandle(details.PipeHostName, details.PipeName, timerExpire, callbackObject);
}

/// <summary>
/// Create MARS handle
/// </summary>
/// <param name="callbackObject">Asynchronous I/O callback object</param>
/// <param name="physicalConnection">SNI connection handle</param>
/// <param name="defaultBufferSize">Default buffer size</param>
/// <param name="async">Asynchronous connection</param>
/// <returns>SNI error status</returns>
public SNIHandle CreateMarsHandle(object callbackObject, SNIHandle physicalConnection, int defaultBufferSize, bool async)
{
SNIMarsConnection connection = SNIMarsManager.Singleton.GetConnection(physicalConnection);
return connection.CreateSession(callbackObject, async);
}

/// <summary>
/// Read packet asynchronously
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace System.Data.SqlClient.SNI
{
internal class TdsParserStateObjectManaged : TdsParserStateObject
{

private SNIMarsConnection _marsConnection = null;
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
Expand Down Expand Up @@ -45,7 +45,13 @@ protected override void CreateSessionHandle(TdsParserStateObject physicalConnect
{
Debug.Assert(physicalConnection is TdsParserStateObjectManaged, "Expected a stateObject of type " + this.GetType());
TdsParserStateObjectManaged managedSNIObject = physicalConnection as TdsParserStateObjectManaged;
_sessionHandle = SNIProxy.Singleton.CreateMarsHandle(this, managedSNIObject.Handle, _outBuff.Length, async);

_sessionHandle = managedSNIObject.CreateMarsSession(this, async);
}

internal SNIMarsHandle CreateMarsSession(object callbackObject, bool async)
{
return _marsConnection.CreateMarsSession(callbackObject, async);
}

protected override uint SNIPacketGetData(object packet, byte[] _inBuff, ref uint dataSize) => SNIProxy.Singleton.PacketGetData(packet as SNIPacket, _inBuff, ref dataSize);
Expand Down Expand Up @@ -84,10 +90,7 @@ internal override void Dispose()
_sniPacket = null;
_sessionHandle = null;
_sniAsyncAttnPacket = null;

_sniPacket = null;
_sessionHandle = null;
_sniAsyncAttnPacket = null;
_marsConnection = null;

DisposeCounters();

Expand Down Expand Up @@ -218,7 +221,16 @@ internal override void ClearAllWritePackets()

internal override uint DisabeSsl() => SNIProxy.Singleton.DisableSsl(Handle);

internal override uint EnableMars(ref uint info) => SNIProxy.Singleton.EnableMars(Handle);
internal override uint EnableMars(ref uint info)
{
_marsConnection = new SNIMarsConnection(Handle);
if (_marsConnection.StartReceive() == TdsEnums.SNI_SUCCESS_IO_PENDING)
{
return TdsEnums.SNI_SUCCESS;
}

return TdsEnums.SNI_ERROR;
}

internal override uint EnableSsl(ref uint info)=> SNIProxy.Singleton.EnableSsl(Handle, info);

Expand Down

0 comments on commit 8d7ff69

Please sign in to comment.