فهرست منبع

Stop listener before waiting for channels to close.
Remove extra exception handling.

drieseng 9 سال پیش
والد
کامیت
65bd07259a
2فایلهای تغییر یافته به همراه3 افزوده شده و 21 حذف شده
  1. 1 18
      src/Renci.SshNet/ForwardedPortLocal.NET.cs
  2. 2 3
      src/Renci.SshNet/ForwardedPortLocal.cs

+ 1 - 18
src/Renci.SshNet/ForwardedPortLocal.NET.cs

@@ -32,24 +32,7 @@ namespace Renci.SshNet
             // consider port started when we're listening for inbound connections
             _status = ForwardedPortStatus.Started;
 
-            try
-            {
-                StartAccept(null);
-            }
-            catch (ObjectDisposedException)
-            {
-                // AcceptAsync will throw an ObjectDisposedException when the server is closed before
-                // the listener has started accepting connections.
-                //
-                // this is only possible when the listener is stopped (from another thread) right
-                // after it was started.
-                StopPort(Session.ConnectionInfo.Timeout);
-            }
-            catch (Exception ex)
-            {
-                StopPort(Session.ConnectionInfo.Timeout);
-                RaiseExceptionEvent(ex);
-            }
+            StartAccept(null);
         }
 
         private void StartAccept(SocketAsyncEventArgs e)

+ 2 - 3
src/Renci.SshNet/ForwardedPortLocal.cs

@@ -131,11 +131,10 @@ namespace Renci.SshNet
 
             // signal existing channels that the port is closing
             base.StopPort(timeout);
+            // prevent new requests from getting processed
+            StopListener();
             // wait for open channels to close
             InternalStop(timeout);
-            // prevent new requests from getting processed before we signal existing
-            // channels that the port is closing
-            StopListener();
             // mark port stopped
             _status = ForwardedPortStatus.Stopped;
         }