From e9f0c6808740e405ca4d1c903d25188935b577f6 Mon Sep 17 00:00:00 2001 From: Oleksandr Poliakov Date: Wed, 12 Nov 2025 16:25:23 -0800 Subject: [PATCH] CSHARP-5743: version 3.5 causes delays and disruptions because it is trying to access a disposed semaphore slim --- src/MongoDB.Driver/Core/Connections/BinaryConnection.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/MongoDB.Driver/Core/Connections/BinaryConnection.cs b/src/MongoDB.Driver/Core/Connections/BinaryConnection.cs index b2f35c6da36..2832cae67b9 100644 --- a/src/MongoDB.Driver/Core/Connections/BinaryConnection.cs +++ b/src/MongoDB.Driver/Core/Connections/BinaryConnection.cs @@ -543,6 +543,7 @@ public async Task ReceiveMessageAsync(OperationContext operatio private void SendBuffer(OperationContext operationContext, IByteBuffer buffer) { + ThrowIfCancelledOrDisposed(operationContext); _sendLock.Wait(operationContext.RemainingTimeout, operationContext.CancellationToken); try { @@ -571,6 +572,7 @@ private void SendBuffer(OperationContext operationContext, IByteBuffer buffer) private async Task SendBufferAsync(OperationContext operationContext, IByteBuffer buffer) { + ThrowIfCancelledOrDisposed(operationContext); await _sendLock.WaitAsync(operationContext.RemainingTimeout, operationContext.CancellationToken).ConfigureAwait(false); try {