Skip to content

Commit 1660109

Browse files
committed
* Acquire / release outstanding confirms semaphore *before* confirms semaphore.
1 parent ebba739 commit 1660109

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

projects/RabbitMQ.Client/Impl/Channel.PublisherConfirms.cs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -282,16 +282,12 @@ await _confirmSemaphore.WaitAsync(reason.CancellationToken)
282282
{
283283
if (_publisherConfirmationsEnabled)
284284
{
285-
/*
286-
if (_publisherConfirmationTrackingEnabled)
285+
if (_publisherConfirmationTrackingEnabled &&
286+
_maxOutstandingConfirmationsSemaphore is not null)
287287
{
288-
if (_maxOutstandingConfirmationsSemaphore is not null)
289-
{
290-
await _maxOutstandingConfirmationsSemaphore.WaitAsync(cancellationToken)
291-
.ConfigureAwait(false);
292-
}
288+
await _maxOutstandingConfirmationsSemaphore.WaitAsync(cancellationToken)
289+
.ConfigureAwait(false);
293290
}
294-
*/
295291

296292
await _confirmSemaphore.WaitAsync(cancellationToken)
297293
.ConfigureAwait(false);
@@ -343,19 +339,19 @@ private async Task MaybeEndPublisherConfirmationTracking(PublisherConfirmationIn
343339
{
344340
if (_publisherConfirmationsEnabled)
345341
{
342+
if (_publisherConfirmationTrackingEnabled &&
343+
_maxOutstandingConfirmationsSemaphore is not null)
344+
{
345+
_maxOutstandingConfirmationsSemaphore.Release();
346+
}
347+
346348
_confirmSemaphore.Release();
347349

348350
if (publisherConfirmationInfo is not null)
349351
{
350352
await publisherConfirmationInfo.MaybeWaitForConfirmationAsync(cancellationToken)
351353
.ConfigureAwait(false);
352354
}
353-
354-
if (_publisherConfirmationTrackingEnabled &&
355-
_maxOutstandingConfirmationsSemaphore is not null)
356-
{
357-
// _maxOutstandingConfirmationsSemaphore.Release();
358-
}
359355
}
360356
}
361357
}

0 commit comments

Comments
 (0)