Skip to content

Commit

Permalink
Added exception handler to fix cases where the network client is corr…
Browse files Browse the repository at this point in the history
…ectly terminated.
  • Loading branch information
kenkendk committed Jan 2, 2018
1 parent 8ebfc44 commit 5294143
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/CoCoL.Network/NetworkClientConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Net.Sockets;
using System.Linq;

namespace CoCoL.Network
{
Expand Down Expand Up @@ -100,8 +101,22 @@ protected override async Task Start()
}
catch(Exception ex)
{
LOG.Fatal("Crashed network client", ex);
throw;
try { Requests.Dispose(); }
catch { }

if (ex.IsRetiredException())
{
if (m_pendingRequests.Values.Any(x => x.Count > 0))
{
LOG.Fatal("Network client is retired, but there were pending messages in queue");
throw;
}
}
else
{
LOG.Fatal("Crashed network client", ex);
throw;
}
}
}

Expand Down

0 comments on commit 5294143

Please sign in to comment.