Fix server adapter memory leak and UnitTests

This commit is contained in:
Christian Kratky
2020-07-25 23:34:30 +02:00
parent 5056843611
commit 4e6aeb91a4
11 changed files with 125 additions and 92 deletions
+7 -7
View File
@@ -58,9 +58,9 @@ namespace MQTTnet.Adapter
public async Task ConnectAsync(TimeSpan timeout, CancellationToken cancellationToken)
{
ThrowIfDisposed();
cancellationToken.ThrowIfCancellationRequested();
ThrowIfDisposed();
try
{
if (timeout == TimeSpan.Zero)
@@ -85,9 +85,9 @@ namespace MQTTnet.Adapter
public async Task DisconnectAsync(TimeSpan timeout, CancellationToken cancellationToken)
{
ThrowIfDisposed();
cancellationToken.ThrowIfCancellationRequested();
ThrowIfDisposed();
try
{
if (timeout == TimeSpan.Zero)
@@ -113,9 +113,9 @@ namespace MQTTnet.Adapter
public async Task SendPacketAsync(MqttBasePacket packet, TimeSpan timeout, CancellationToken cancellationToken)
{
ThrowIfDisposed();
cancellationToken.ThrowIfCancellationRequested();
ThrowIfDisposed();
try
{
await _writerSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false);
@@ -169,8 +169,8 @@ namespace MQTTnet.Adapter
public async Task<MqttBasePacket> ReceivePacketAsync(TimeSpan timeout, CancellationToken cancellationToken)
{
ThrowIfDisposed();
cancellationToken.ThrowIfCancellationRequested();
ThrowIfDisposed();
try
{