mirror of
https://github.com/sshnet/SSH.NET.git
synced 2026-09-11 13:39:09 +00:00
Ignore ObjectDisposedException in AcceptAsync while stopping or stopped.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
|
||||
@@ -79,9 +79,22 @@ namespace Renci.SshNet
|
||||
// only accept new connections while we are started
|
||||
if (IsStarted)
|
||||
{
|
||||
if (!_listener.AcceptAsync(e))
|
||||
try
|
||||
{
|
||||
AcceptCompleted(null, e);
|
||||
if (!_listener.AcceptAsync(e))
|
||||
{
|
||||
AcceptCompleted(null, e);
|
||||
}
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
if (_status == ForwardedPortStatus.Stopped || _status == ForwardedPortStatus.Stopped)
|
||||
{
|
||||
// ignore ObjectDisposedException while stopping or stopped
|
||||
return;
|
||||
}
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user