Skip to content

Commit 6bb7655

Browse files
fix race condition with DisposeAsync & ReleaseLease & TryAcquireLease
1 parent 4297acb commit 6bb7655

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Ydb.Sdk/src/Ado/Session/ImplicitSessionSource.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ private bool TryAcquireLease()
4242

4343
internal void ReleaseLease()
4444
{
45-
if (Interlocked.Decrement(ref _activeLeaseCount) == 0 && Volatile.Read(ref _isDisposed) == 1)
45+
Interlocked.Decrement(ref _activeLeaseCount);
46+
47+
if (Volatile.Read(ref _isDisposed) == 1 && _activeLeaseCount == 0)
4648
_drainedTcs.TrySetResult();
4749
}
4850

0 commit comments

Comments
 (0)