Fix a deadlock when an exception is fired while connecting.

This commit is contained in:
Christian Kratky
2018-10-04 20:53:02 +02:00
parent 56a1530cee
commit 0c2ab9b231
3 changed files with 76 additions and 18 deletions
+5 -1
View File
@@ -150,6 +150,9 @@ namespace MQTTnet.Adapter
return packet;
}
catch (OperationCanceledException)
{
}
catch (Exception exception)
{
if (IsWrappedException(exception))
@@ -237,7 +240,8 @@ namespace MQTTnet.Adapter
{
if (exception is IOException && exception.InnerException is SocketException socketException)
{
if (socketException.SocketErrorCode == SocketError.ConnectionAborted)
if (socketException.SocketErrorCode == SocketError.ConnectionAborted ||
socketException.SocketErrorCode == SocketError.OperationAborted)
{
throw new OperationCanceledException();
}