Skip to content

Commit

Permalink
Fix SocketException from AcceptTcpClientAsync during Dispose (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsimons committed Jan 7, 2021
1 parent 56702c5 commit df3052f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Rnwood.SmtpServer/SmtpServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,17 @@ private async Task AcceptNextClient()
{
tcpClient = await this.listener.AcceptTcpClientAsync().ConfigureAwait(false);
}
catch (SocketException)
{
if (this.IsRunning)
{
throw;
}

this.logger.LogDebug("Got SocketException on listener, shutting down");

// normal - caused by _listener.Stop();
}
catch (InvalidOperationException)
{
if (this.IsRunning)
Expand Down

0 comments on commit df3052f

Please sign in to comment.