@@ -589,7 +589,7 @@ public Task ConnectionTuneOkAsync(ushort channelMax, uint frameMax, ushort heart
589
589
return ModelSendAsync ( method , cancellationToken ) . AsTask ( ) ;
590
590
}
591
591
592
- protected void HandleBasicAck ( IncomingCommand cmd )
592
+ protected async Task < bool > HandleBasicAck ( IncomingCommand cmd , CancellationToken cancellationToken )
593
593
{
594
594
var ack = new BasicAck ( cmd . MethodSpan ) ;
595
595
if ( ! _basicAcksWrapper . IsEmpty )
@@ -598,10 +598,12 @@ protected void HandleBasicAck(IncomingCommand cmd)
598
598
_basicAcksWrapper . Invoke ( this , args ) ;
599
599
}
600
600
601
- HandleAckNack ( ack . _deliveryTag , ack . _multiple , false ) ;
601
+ await HandleAckNack ( ack . _deliveryTag , ack . _multiple , false , cancellationToken )
602
+ . ConfigureAwait ( false ) ;
603
+ return true ;
602
604
}
603
605
604
- protected void HandleBasicNack ( IncomingCommand cmd )
606
+ protected async Task < bool > HandleBasicNack ( IncomingCommand cmd , CancellationToken cancellationToken )
605
607
{
606
608
var nack = new BasicNack ( cmd . MethodSpan ) ;
607
609
if ( ! _basicNacksWrapper . IsEmpty )
@@ -611,7 +613,9 @@ protected void HandleBasicNack(IncomingCommand cmd)
611
613
_basicNacksWrapper . Invoke ( this , args ) ;
612
614
}
613
615
614
- HandleAckNack ( nack . _deliveryTag , nack . _multiple , true ) ;
616
+ await HandleAckNack ( nack . _deliveryTag , nack . _multiple , true , cancellationToken )
617
+ . ConfigureAwait ( false ) ;
618
+ return true ;
615
619
}
616
620
617
621
protected async Task < bool > HandleBasicCancelAsync ( IncomingCommand cmd , CancellationToken cancellationToken )
@@ -1829,7 +1833,7 @@ await tokenRegistration.DisposeAsync()
1829
1833
1830
1834
// NOTE: this method is internal for its use in this test:
1831
1835
// TestWaitForConfirmsWithTimeoutAsync_MessageNacked_WaitingHasTimedout_ReturnFalse
1832
- internal void HandleAckNack ( ulong deliveryTag , bool multiple , bool isNack )
1836
+ internal async Task HandleAckNack ( ulong deliveryTag , bool multiple , bool isNack , CancellationToken cancellationToken = default )
1833
1837
{
1834
1838
// Only do this if confirms are enabled *and* the library is tracking confirmations
1835
1839
if ( ConfirmsAreEnabled && _trackConfirmations )
@@ -1839,7 +1843,8 @@ internal void HandleAckNack(ulong deliveryTag, bool multiple, bool isNack)
1839
1843
throw new InvalidOperationException ( InternalConstants . BugFound ) ;
1840
1844
}
1841
1845
// let's take a lock so we can assume that deliveryTags are unique, never duplicated and always sorted
1842
- _confirmSemaphore . Wait ( ) ;
1846
+ await _confirmSemaphore . WaitAsync ( cancellationToken )
1847
+ . ConfigureAwait ( false ) ;
1843
1848
try
1844
1849
{
1845
1850
// No need to do anything if there are no delivery tags in the list
0 commit comments