From e92cd4a8912a2f0fefe695bf389596e315a0643b Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Thu, 29 Oct 2009 11:36:05 +0000 Subject: Before terminating the SSH tunnel task check that it's actually running to accommodate tunnels that suddenly disappear. --- Source/SPSSHTunnel.m | 9 +++++++-- 1 file 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]; } -- cgit v1.2.3