File tree Expand file tree Collapse file tree 2 files changed +5
-23
lines changed Expand file tree Collapse file tree 2 files changed +5
-23
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ public partial class ForwardedPortDynamic
17
17
18
18
partial void InternalStart ( )
19
19
{
20
+ InitializePendingChannelCountdown ( ) ;
21
+
20
22
var ip = IPAddress . Any ;
21
23
if ( ! string . IsNullOrEmpty ( BoundHost ) )
22
24
{
@@ -32,29 +34,10 @@ partial void InternalStart()
32
34
Session . ErrorOccured += Session_ErrorOccured ;
33
35
Session . Disconnected += Session_Disconnected ;
34
36
35
- InitializePendingChannelCountdown ( ) ;
37
+ StartAccept ( null ) ;
36
38
37
39
// consider port started when we're listening for inbound connections
38
40
_status = ForwardedPortStatus . Started ;
39
-
40
- try
41
- {
42
- StartAccept ( null ) ;
43
- }
44
- catch ( ObjectDisposedException )
45
- {
46
- // AcceptAsync will throw an ObjectDisposedException when the server is closed before
47
- // the listener has started accepting connections.
48
- //
49
- // this is only possible when the listener is stopped (from another thread) right
50
- // after it was started.
51
- StopPort ( Session . ConnectionInfo . Timeout ) ;
52
- }
53
- catch ( Exception ex )
54
- {
55
- StopPort ( Session . ConnectionInfo . Timeout ) ;
56
- RaiseExceptionEvent ( ex ) ;
57
- }
58
41
}
59
42
60
43
private void StartAccept ( SocketAsyncEventArgs e )
Original file line number Diff line number Diff line change @@ -82,11 +82,10 @@ protected override void StopPort(TimeSpan timeout)
82
82
83
83
// signal existing channels that the port is closing
84
84
base . StopPort ( timeout ) ;
85
+ // prevent new requests from getting processed
86
+ StopListener ( ) ;
85
87
// wait for open channels to close
86
88
InternalStop ( timeout ) ;
87
- // prevent new requests from getting processed before we signal existing
88
- // channels that the port is closing
89
- StopListener ( ) ;
90
89
// mark port stopped
91
90
_status = ForwardedPortStatus . Stopped ;
92
91
}
You can’t perform that action at this time.
0 commit comments