Skip to content

Commit e83f966

Browse files
committed
Mop-up debug assertion and comments in TdsParserStateObject
1 parent c7ef9b6 commit e83f966

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ internal uint Status
136136
// cancel request.
137137
internal void Cancel(object caller)
138138
{
139+
Debug.Assert(caller != null, "Null caller for Cancel!");
140+
Debug.Assert(caller is SqlCommand || caller is SqlDataReader, "Calling API with invalid caller type: " + caller.GetType());
141+
139142
bool hasLock = false;
140143
try
141144
{
@@ -147,8 +150,7 @@ internal void Cancel(object caller)
147150
{ // Lock for the time being - since we need to synchronize the attention send.
148151
// This lock is also protecting against concurrent close and async continuations
149152

150-
// don't allow objectID -1 since it is reserved for 'not associated with a command'
151-
// yes, the 2^32-1 comand won't cancel - but it also won't cancel when we don't want it
153+
// Ensure that, once we have the lock, that we are still the owner
152154
if ((!_cancelled) && (_cancellationOwner.Target == caller))
153155
{
154156
_cancelled = true;

0 commit comments

Comments
 (0)