You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Note - it's possible that when native calls managed that an asynchronous exception
401
-
// could occur in the native->managed transition, which would
402
-
// have two impacts:
403
-
// 1) user event not called
404
-
// 2) DecrementPendingCallbacks not called, which would mean this object would be leaked due
405
-
// to the outstanding GCRoot until AppDomain.Unload.
406
-
// We live with the above for the time being due to the constraints of the current
407
-
// reliability infrastructure provided by the CLR.
408
-
SqlClientEventSource.Log.TryTraceEvent("TdsParserStateObject.ReadAsyncCallback | Info | State Object Id {0}, received error {1} on idle connection",_objectID,(int)error);
// Connection was closed by another thread before we parsed the packet, so no error was added to the collection
519
-
throwADP.ClosedConnectionError();
520
-
}
521
-
}
522
-
catch(Exceptionex)
523
-
{
524
-
if(source.TrySetException(ex))
525
-
{
526
-
// There was an exception, and it was successfully stored in the task
527
-
captureSuccess=true;
528
-
}
529
-
}
530
-
531
-
if(!captureSuccess)
532
-
{
533
-
// Either there was no exception, or the task was already completed
534
-
// This is unusual, but possible if a fatal timeout occurred on another thread (which should mean that the connection is now broken)
535
-
Debug.Assert(_parser.State==TdsParserState.Broken||_parser.State==TdsParserState.Closed||_parser.Connection.IsConnectionDoomed,"Failed to capture exception while the connection was still healthy");
536
-
537
-
// The safest thing to do is to ensure that the connection is broken and attempt to cancel the task
538
-
// This must be done from another thread to not block the callback thread
// Connection was closed by another thread before we parsed the packet, so no error was added to the collection
598
-
throwADP.ClosedConnectionError();
599
-
}
600
-
}
601
-
catch(Exceptionex)
602
-
{
603
-
if(source.TrySetException(ex))
604
-
{
605
-
// There was an exception, and it was successfully stored in the task
606
-
captureSuccess=true;
607
-
}
608
-
}
609
-
610
-
if(!captureSuccess)
611
-
{
612
-
// Either there was no exception, or the task was already completed
613
-
// This is unusual, but possible if a fatal timeout occurred on another thread (which should mean that the connection is now broken)
614
-
Debug.Assert(_parser.State==TdsParserState.Broken||_parser.State==TdsParserState.Closed||_parser.Connection.IsConnectionDoomed,"Failed to capture exception while the connection was still healthy");
615
-
616
-
// The safest thing to do is to ensure that the connection is broken and attempt to cancel the task
617
-
// This must be done from another thread to not block the callback thread
618
-
Task.Factory.StartNew(()=>
619
-
{
620
-
_parser.State=TdsParserState.Broken;
621
-
_parser.Connection.BreakConnection();
622
-
source.TrySetCanceled();
623
-
});
624
-
}
625
-
}
626
-
627
489
#pragma warning disable 420// a reference to a volatile field will not be treated as volatile
0 commit comments