diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPSSHTunnel.m | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Source/SPSSHTunnel.m b/Source/SPSSHTunnel.m index d6a5756f..18ec38b3 100644 --- a/Source/SPSSHTunnel.m +++ b/Source/SPSSHTunnel.m @@ -352,8 +352,13 @@ - (void)disconnect { if (connectionState == PROXY_STATE_IDLE) return; - [task terminate]; - connectionState = PROXY_STATE_IDLE; + + // Before terminating the tunnel, check that it's actually running. This is to accommodate tunnels which + // suddenly disappear as a result of network disconnections. + if ([task isRunning]) [task terminate]; + + connectionState = PROXY_STATE_IDLE; + if (delegate) [delegate performSelectorOnMainThread:stateChangeSelector withObject:self waitUntilDone:NO]; } |