diff --git a/projects/RabbitMQ.Client/client/impl/AutorecoveringConnection.cs b/projects/RabbitMQ.Client/client/impl/AutorecoveringConnection.cs index 19391278c..f4b89fc6c 100644 --- a/projects/RabbitMQ.Client/client/impl/AutorecoveringConnection.cs +++ b/projects/RabbitMQ.Client/client/impl/AutorecoveringConnection.cs @@ -183,7 +183,7 @@ public async ValueTask CreateNonRecoveringChannelAsync(Can public override string ToString() => $"AutorecoveringConnection({InnerConnection.Id},{Endpoint},{GetHashCode()})"; - internal Task CloseFrameHandlerAsync() + internal ValueTask CloseFrameHandlerAsync() { return InnerConnection.FrameHandler.CloseAsync(CancellationToken.None); } diff --git a/projects/RabbitMQ.Client/client/impl/IFrameHandler.cs b/projects/RabbitMQ.Client/client/impl/IFrameHandler.cs index f65e0ffde..672f6a3bb 100644 --- a/projects/RabbitMQ.Client/client/impl/IFrameHandler.cs +++ b/projects/RabbitMQ.Client/client/impl/IFrameHandler.cs @@ -54,7 +54,7 @@ internal interface IFrameHandler ///Socket write timeout. System.Threading.Timeout.InfiniteTimeSpan signals "infinity". TimeSpan WriteTimeout { set; } - Task CloseAsync(CancellationToken cancellationToken); + ValueTask CloseAsync(CancellationToken cancellationToken); ///Read a frame from the underlying ///transport. Returns null if the read operation timed out @@ -66,7 +66,7 @@ internal interface IFrameHandler /// bool TryReadFrame(InboundFrame frame); - Task SendProtocolHeaderAsync(CancellationToken cancellationToken); + ValueTask SendProtocolHeaderAsync(CancellationToken cancellationToken); ValueTask WriteAsync(RentedMemory frames, CancellationToken cancellationToken); } diff --git a/projects/RabbitMQ.Client/client/impl/SocketFrameHandler.cs b/projects/RabbitMQ.Client/client/impl/SocketFrameHandler.cs index ec970fe93..6f6cbf343 100644 --- a/projects/RabbitMQ.Client/client/impl/SocketFrameHandler.cs +++ b/projects/RabbitMQ.Client/client/impl/SocketFrameHandler.cs @@ -157,7 +157,7 @@ public static async Task CreateAsync(AmqpTcpEndpoint amqpTcp return socketFrameHandler; } - public async Task CloseAsync(CancellationToken cancellationToken) + public async ValueTask CloseAsync(CancellationToken cancellationToken) { if (_closed) { @@ -216,7 +216,7 @@ public bool TryReadFrame(InboundFrame frame) _amqpTcpEndpoint.MaxInboundMessageBodySize, frame); } - public async Task SendProtocolHeaderAsync(CancellationToken cancellationToken) + public async ValueTask SendProtocolHeaderAsync(CancellationToken cancellationToken) { await _pipeWriter.WriteAsync(Amqp091ProtocolHeader, cancellationToken) .ConfigureAwait(false); diff --git a/projects/Test/Integration/TestConnectionShutdown.cs b/projects/Test/Integration/TestConnectionShutdown.cs index 568a7ff8e..902421967 100644 --- a/projects/Test/Integration/TestConnectionShutdown.cs +++ b/projects/Test/Integration/TestConnectionShutdown.cs @@ -100,13 +100,13 @@ public async Task TestDisposedWithSocketClosedOutOfBand() }; var c = (AutorecoveringConnection)_conn; - Task frameHandlerCloseTask = c.CloseFrameHandlerAsync(); + ValueTask frameHandlerCloseTask = c.CloseFrameHandlerAsync(); try { _conn.Dispose(); await WaitAsync(tcs, WaitSpan, "channel shutdown"); - await frameHandlerCloseTask.WaitAsync(WaitSpan); + await frameHandlerCloseTask.AsTask().WaitAsync(WaitSpan); } finally {