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
Remove long running option from MARS (#28627)
Browse files Browse the repository at this point in the history
  • Loading branch information
saurabh500 authored Mar 30, 2018
1 parent f52fa89 commit ee4aa4f
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ internal abstract class SNIHandle
/// </summary>
/// <param name="packet">SNI packet</param>
/// <returns>SNI error code</returns>
public abstract uint ReceiveAsync(ref SNIPacket packet, bool isMars = false);
public abstract uint ReceiveAsync(ref SNIPacket packet);

/// <summary>
/// Enable SSL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public uint ReceiveAsync(ref SNIPacket packet)
{
lock (this)
{
return _lowerHandle.ReceiveAsync(ref packet, isMars: true);
return _lowerHandle.ReceiveAsync(ref packet);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public override uint SendAsync(SNIPacket packet, bool disposePacketAfterSendAsyn
/// </summary>
/// <param name="packet">SNI packet</param>
/// <returns>SNI error code</returns>
public override uint ReceiveAsync(ref SNIPacket packet, bool isMars = true)
public override uint ReceiveAsync(ref SNIPacket packet)
{
lock (_receivedPacketQueue)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,13 @@ public override uint Receive(out SNIPacket packet, int timeout)
}
}

public override uint ReceiveAsync(ref SNIPacket packet, bool isMars = false)
public override uint ReceiveAsync(ref SNIPacket packet)
{
packet = new SNIPacket(_bufferSize);

try
{
packet.ReadFromStreamAsync(_stream, _receiveCallback, isMars);
packet.ReadFromStreamAsync(_stream, _receiveCallback);
return TdsEnums.SNI_SUCCESS_IO_PENDING;
}
catch (ObjectDisposedException ode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,22 +245,13 @@ public void Reset()
/// </summary>
/// <param name="stream">Stream to read from</param>
/// <param name="callback">Completion callback</param>
public void ReadFromStreamAsync(Stream stream, SNIAsyncCallback callback, bool isMars)
public void ReadFromStreamAsync(Stream stream, SNIAsyncCallback callback)
{
bool error = false;
TaskContinuationOptions options = TaskContinuationOptions.DenyChildAttach;
// MARS operations during Sync ADO.Net API calls are Sync over Async. Each API call can request
// threads to execute the async reads. MARS operations do not get the threads quickly enough leading to timeout
// To fix the MARS thread exhaustion issue LongRunning continuation option is a temporary solution with its own drawbacks,
// and should be removed after evaluating how to fix MARS threading issues efficiently
if (isMars)
{
options |= TaskContinuationOptions.LongRunning;
}


stream.ReadAsync(_data, 0, _capacity, CancellationToken.None).ContinueWith(t =>
{
Exception e = t.Exception != null ? t.Exception.InnerException : null;
Exception e = t.Exception?.InnerException;
if (e != null)
{
SNILoadHandle.SingletonInstance.LastError = new SNIError(SNIProviders.TCP_PROV, SNICommon.InternalExceptionError, e);
Expand All @@ -285,7 +276,7 @@ public void ReadFromStreamAsync(Stream stream, SNIAsyncCallback callback, bool i
callback(this, error ? TdsEnums.SNI_ERROR : TdsEnums.SNI_SUCCESS);
},
CancellationToken.None,
options,
TaskContinuationOptions.DenyChildAttach,
TaskScheduler.Default);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ private SNINpHandle CreateNpHandle(DataSource details, long timerExpire, object
/// <param name="handle">SNI handle</param>
/// <param name="packet">Packet</param>
/// <returns>SNI error status</returns>
public uint ReadAsync(SNIHandle handle, out SNIPacket packet, bool isMars = false)
public uint ReadAsync(SNIHandle handle, out SNIPacket packet)
{
packet = null;
return handle.ReceiveAsync(ref packet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -537,13 +537,13 @@ public override uint SendAsync(SNIPacket packet, bool disposePacketAfterSendAsyn
/// </summary>
/// <param name="packet">SNI packet</param>
/// <returns>SNI error code</returns>
public override uint ReceiveAsync(ref SNIPacket packet, bool isMars = false)
public override uint ReceiveAsync(ref SNIPacket packet)
{
packet = new SNIPacket(_bufferSize);

try
{
packet.ReadFromStreamAsync(_stream, _receiveCallback, isMars);
packet.ReadFromStreamAsync(_stream, _receiveCallback);
return TdsEnums.SNI_SUCCESS_IO_PENDING;
}
catch (Exception e) when (e is ObjectDisposedException || e is SocketException || e is IOException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ internal override uint CheckConnection()
internal override object ReadAsync(out uint error, ref object handle)
{
SNIPacket packet;
error = SNIProxy.Singleton.ReadAsync((SNIHandle)handle, out packet, isMars: _parser.MARSOn);
error = SNIProxy.Singleton.ReadAsync((SNIHandle)handle, out packet);
return packet;
}

Expand Down

0 comments on commit ee4aa4f

Please sign in to comment.