Skip to content

Commit

Permalink
Revert unwanted changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cheenamalhotra committed Nov 18, 2020
1 parent 7d341af commit f76e1c0
Showing 1 changed file with 31 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ public override uint Receive(out SNIPacket packet, int timeout)
try
{
SNIPacket errorPacket;
lock (this)
{
packet = null;
try
{
Expand Down Expand Up @@ -220,6 +222,7 @@ public override uint Receive(out SNIPacket packet, int timeout)
}
return TdsEnums.SNI_SUCCESS;
}
}
finally
{
SqlClientEventSource.Log.TrySNIScopeLeaveEvent(scopeID);
Expand Down Expand Up @@ -268,43 +271,40 @@ public override uint Send(SNIPacket packet)
bool releaseLock = false;
try
{
lock (this)
// is the packet is marked out out-of-band (attention packets only) it must be
// sent immediately even if a send of recieve operation is already in progress
// because out of band packets are used to cancel ongoing operations
// so try to take the lock if possible but continue even if it can't be taken
if (packet.IsOutOfBand)
{
Monitor.TryEnter(this, ref releaseLock);
}
else
{
// is the packet is marked out out-of-band (attention packets only) it must be
// sent immediately even if a send of recieve operation is already in progress
// because out of band packets are used to cancel ongoing operations
// so try to take the lock if possible but continue even if it can't be taken
if (packet.IsOutOfBand)
Monitor.Enter(this);
releaseLock = true;
}

// this lock ensures that two packets are not being written to the transport at the same time
// so that sending a standard and an out-of-band packet are both written atomically no data is
// interleaved
lock (_sendSync)
{
try
{
Monitor.TryEnter(this, ref releaseLock);
packet.WriteToStream(_stream);
return TdsEnums.SNI_SUCCESS;
}
else
catch (ObjectDisposedException ode)
{
Monitor.Enter(this);
releaseLock = true;
SqlClientEventSource.Log.TrySNITraceEvent("<sc.SNI.SNINpHandle.Send |SNI|ERR> ObjectDisposedException message = {0}.", ode.Message);
return ReportErrorAndReleasePacket(packet, ode);
}

// this lock ensures that two packets are not being written to the transport at the same time
// so that sending a standard and an out-of-band packet are both written atomically no data is
// interleaved
lock (_sendSync)
catch (IOException ioe)
{
try
{
packet.WriteToStream(_stream);
return TdsEnums.SNI_SUCCESS;
}
catch (ObjectDisposedException ode)
{
SqlClientEventSource.Log.TrySNITraceEvent("<sc.SNI.SNINpHandle.Send |SNI|ERR> ObjectDisposedException message = {0}.", ode.Message);
return ReportErrorAndReleasePacket(packet, ode);
}
catch (IOException ioe)
{
SqlClientEventSource.Log.TrySNITraceEvent("<sc.SNI.SNINpHandle.Send |SNI|ERR> IOException message = {0}.", ioe.Message);

return ReportErrorAndReleasePacket(packet, ioe);
}
SqlClientEventSource.Log.TrySNITraceEvent("<sc.SNI.SNINpHandle.Send |SNI|ERR> IOException message = {0}.", ioe.Message);

return ReportErrorAndReleasePacket(packet, ioe);
}
}
}
Expand Down

0 comments on commit f76e1c0

Please sign in to comment.