From 4fed80c2d0c9e08e4364700eaf358bb37ed28d6f Mon Sep 17 00:00:00 2001 From: Christian Date: Thu, 20 Dec 2018 21:08:07 +0100 Subject: [PATCH 1/5] Update appveyor.yml --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 24ea5f4b..4d7b08a0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -15,4 +15,4 @@ build: test_script: - cmd: dotnet vstest "%APPVEYOR_BUILD_FOLDER%\Tests\MQTTnet.Core.Tests\bin\Release\netcoreapp2.1\MQTTnet.Core.Tests.dll" -- cmd: dotnet vstest "%APPVEYOR_BUILD_FOLDER%\Tests\MQTTnet.TestApp.AspNetCore\bin\Release\netcoreapp2.1\MQTTnet.TestApp.AspNetCore.dll" +- cmd: dotnet vstest "%APPVEYOR_BUILD_FOLDER%\Tests\MQTTnet.AspNetCore.Tests\bin\Release\netcoreapp2.1\MQTTnet.AspNetCore.Tests.dll" From 107e96ff7dfbd8ab0a8932e0a7f8ac3a7ea5fbe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20B=C3=A4urle?= Date: Mon, 7 Jan 2019 11:54:10 +0100 Subject: [PATCH 2/5] Don't cancel token before stop session manager --- Source/MQTTnet/Server/MqttServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/MQTTnet/Server/MqttServer.cs b/Source/MQTTnet/Server/MqttServer.cs index 737d7560..cb3e84e7 100644 --- a/Source/MQTTnet/Server/MqttServer.cs +++ b/Source/MQTTnet/Server/MqttServer.cs @@ -120,10 +120,10 @@ namespace MQTTnet.Server { return; } - - _cancellationTokenSource.Cancel(false); _clientSessionsManager.Stop(); + + _cancellationTokenSource.Cancel(false); foreach (var adapter in _adapters) { From 5090cfb411e063f12b92cb10b0738429ed2811af Mon Sep 17 00:00:00 2001 From: Christian Date: Tue, 5 Mar 2019 07:47:31 +0100 Subject: [PATCH 3/5] Fix memory leak in AsyncAutoResetEvent. --- .../MQTTnet/Internal/AsyncAutoResetEvent.cs | 24 +++++++++++++++++- .../AsyncAutoResentEventTests.cs | 25 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/Source/MQTTnet/Internal/AsyncAutoResetEvent.cs b/Source/MQTTnet/Internal/AsyncAutoResetEvent.cs index a90b98e4..a6e96211 100644 --- a/Source/MQTTnet/Internal/AsyncAutoResetEvent.cs +++ b/Source/MQTTnet/Internal/AsyncAutoResetEvent.cs @@ -9,6 +9,7 @@ namespace MQTTnet.Internal public class AsyncAutoResetEvent { private readonly LinkedList> _waiters = new LinkedList>(); + private bool _isSignaled; public AsyncAutoResetEvent() @@ -21,6 +22,17 @@ namespace MQTTnet.Internal _isSignaled = signaled; } + public int WaitersCount + { + get + { + lock (_waiters) + { + return _waiters.Count; + } + } + } + public Task WaitOneAsync() { return WaitOneAsync(CancellationToken.None); @@ -59,7 +71,17 @@ namespace MQTTnet.Internal _waiters.AddLast(tcs); } - var winner = await Task.WhenAny(tcs.Task, Task.Delay(timeout, cancellationToken)).ConfigureAwait(false); + Task winner; + if (timeout == Timeout.InfiniteTimeSpan) + { + await tcs.Task.ConfigureAwait(false); + winner = tcs.Task; + } + else + { + winner = await Task.WhenAny(tcs.Task, Task.Delay(timeout, cancellationToken)).ConfigureAwait(false); + } + var taskWasSignaled = winner == tcs.Task; if (taskWasSignaled) { diff --git a/Tests/MQTTnet.Core.Tests/AsyncAutoResentEventTests.cs b/Tests/MQTTnet.Core.Tests/AsyncAutoResentEventTests.cs index 188f54fb..074b0099 100644 --- a/Tests/MQTTnet.Core.Tests/AsyncAutoResentEventTests.cs +++ b/Tests/MQTTnet.Core.Tests/AsyncAutoResentEventTests.cs @@ -17,6 +17,31 @@ namespace MQTTnet.Core.Tests _aare = new AsyncAutoResetEvent(); } + [TestMethod] + public async Task Cleanup_Waiters() + { + var @lock = new AsyncAutoResetEvent(); + + var waitOnePassed = false; + + Task.Run(async () => + { + await @lock.WaitOneAsync(TimeSpan.FromSeconds(2)); + waitOnePassed = true; + }); + + await Task.Delay(500); + + Assert.AreEqual(1, @lock.WaitersCount); + + @lock.Set(); + + await Task.Delay(1000); + + Assert.IsTrue(waitOnePassed); + Assert.AreEqual(0, @lock.WaitersCount); + } + [TestMethod] public async Task SingleThreadedPulse() { From de8bcb7f37b1b9cb7ea6e0cb55885aedcc3c6391 Mon Sep 17 00:00:00 2001 From: Christian Kratky Date: Sat, 9 Mar 2019 19:24:04 +0100 Subject: [PATCH 4/5] Update docs. --- Build/MQTTnet.AspNetCore.nuspec | 2 +- Build/MQTTnet.Extensions.ManagedClient.nuspec | 2 +- Build/MQTTnet.Extensions.Rpc.nuspec | 2 +- Build/MQTTnet.nuspec | 14 +------------- 4 files changed, 4 insertions(+), 16 deletions(-) diff --git a/Build/MQTTnet.AspNetCore.nuspec b/Build/MQTTnet.AspNetCore.nuspec index e57035e0..241582a2 100644 --- a/Build/MQTTnet.AspNetCore.nuspec +++ b/Build/MQTTnet.AspNetCore.nuspec @@ -14,7 +14,7 @@ Copyright Christian Kratky 2016-2018 MQTT Message Queue Telemetry Transport MQTTClient MQTTServer Server MQTTBroker Broker NETStandard IoT InternetOfThings Messaging Hardware Arduino Sensor Actuator M2M ESP Smart Home Cities Automation Xamarin - + diff --git a/Build/MQTTnet.Extensions.ManagedClient.nuspec b/Build/MQTTnet.Extensions.ManagedClient.nuspec index a34c8d6e..af18c0f6 100644 --- a/Build/MQTTnet.Extensions.ManagedClient.nuspec +++ b/Build/MQTTnet.Extensions.ManagedClient.nuspec @@ -14,7 +14,7 @@ Copyright Christian Kratky 2016-2018 MQTT Message Queue Telemetry Transport MQTTClient MQTTServer Server MQTTBroker Broker NETStandard IoT InternetOfThings Messaging Hardware Arduino Sensor Actuator M2M ESP Smart Home Cities Automation Xamarin - + diff --git a/Build/MQTTnet.Extensions.Rpc.nuspec b/Build/MQTTnet.Extensions.Rpc.nuspec index bef33228..2a443728 100644 --- a/Build/MQTTnet.Extensions.Rpc.nuspec +++ b/Build/MQTTnet.Extensions.Rpc.nuspec @@ -14,7 +14,7 @@ Copyright Christian Kratky 2016-2018 MQTT Message Queue Telemetry Transport MQTTClient MQTTServer Server MQTTBroker Broker NETStandard IoT InternetOfThings Messaging Hardware Arduino Sensor Actuator M2M ESP Smart Home Cities Automation Xamarin - + diff --git a/Build/MQTTnet.nuspec b/Build/MQTTnet.nuspec index 5814a730..20e9daea 100644 --- a/Build/MQTTnet.nuspec +++ b/Build/MQTTnet.nuspec @@ -10,19 +10,7 @@ https://raw.githubusercontent.com/chkr1011/MQTTnet/master/Images/Logo_128x128.png false MQTTnet is a high performance .NET library for MQTT based communication. It provides a MQTT client and a MQTT server (broker). - * [Core] Updated nuget packages due to security issues. -* [Client] Fixed wrong behavior of publish method when client is disconnecting (thanks to @PaulFake). -* [Client] Added readonly property for accessing options. -* [ManagedClient] Added max pending messages count option. -* [ManagedClient] Add pending messages overflow strategy option. -* [ManagedClient] Fixed an issue which deletes the wrong message from the internal queue (thanks to @PaulFake). -* [ManagedClient] Added readonly property for accessing options. -* [Server] Added new method which exposes all retained messages. -* [Server] Removed (wrong) setter from the server options interface. -* [Server] Fixed cpu spike in case a client disconnects (issue 421). -* [Server] Fixed concurrent sends with Aspnetcore.Connections.Abstractions based transport. -* [Server] Fixed wrong retain flag when distributing application messages (thanks to @trev0115). -* [Server] Fixed issue which closes a connection when reconnecting with the same client ID (thanks to @fogzot). + * [Core] Fixed a memory leak when processing lots of messages (thanks to @tschanko) Copyright Christian Kratky 2016-2018 MQTT Message Queue Telemetry Transport MQTTClient MQTTServer Server MQTTBroker Broker NETStandard IoT InternetOfThings Messaging Hardware Arduino Sensor Actuator M2M ESP Smart Home Cities Automation Xamarin From 007991f0731151eace855ba59f6c003a25f86b91 Mon Sep 17 00:00:00 2001 From: Christian Kratky Date: Sun, 10 Mar 2019 10:11:43 +0100 Subject: [PATCH 5/5] Update docs. --- Build/MQTTnet.nuspec | 1 + 1 file changed, 1 insertion(+) diff --git a/Build/MQTTnet.nuspec b/Build/MQTTnet.nuspec index 20e9daea..8ac9e692 100644 --- a/Build/MQTTnet.nuspec +++ b/Build/MQTTnet.nuspec @@ -11,6 +11,7 @@ false MQTTnet is a high performance .NET library for MQTT based communication. It provides a MQTT client and a MQTT server (broker). * [Core] Fixed a memory leak when processing lots of messages (thanks to @tschanko) +* [Server] Fixed wrong will message behavior when stopping server (thanks to @JohBa) Copyright Christian Kratky 2016-2018 MQTT Message Queue Telemetry Transport MQTTClient MQTTServer Server MQTTBroker Broker NETStandard IoT InternetOfThings Messaging Hardware Arduino Sensor Actuator M2M ESP Smart Home Cities Automation Xamarin