From 52011b886bc031b99a1a359fa17b5e5469e2046d Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Tue, 13 Jul 2010 00:33:49 +0000 Subject: Improve handling of network drops, including a new automatic reconnection attempt, as well as improved handling of networks not present. This addresses Issue #657. In MCPKit: - Disable MySQL automatic reconnection, and add our own reconnection code for greater consistency - If no network is available, delay reconnects by a short period to allow the network to come back up - Improved handling of proxy disconnects In SPSSHTunnel: - Improved handling of SSH tunnel disconnects, improving automatic reconnection via MCPKit and fixing potential memory/logic tramping. Also remove the "Retry" button from the Disconnected dialog, leaving only the choices "Reconnect" or "Disconnect". --- Source/SPSSHTunnel.m | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'Source') diff --git a/Source/SPSSHTunnel.m b/Source/SPSSHTunnel.m index 59acb9e0..0cf2a724 100644 --- a/Source/SPSSHTunnel.m +++ b/Source/SPSSHTunnel.m @@ -278,7 +278,6 @@ taskArguments = [[NSMutableArray alloc] init]; [taskArguments addObject:@"-N"]; // Tunnel only [taskArguments addObject:@"-v"]; // Verbose mode for messages -// [taskArguments addObject:@"-C"]; // TODO: compression? [taskArguments addObject:@"-M"]; // Places the ssh client into 'master' mode for connection sharing [taskArguments addObject:@"-o ExitOnForwardFailure=yes"]; [taskArguments addObject:[NSString stringWithFormat:@"-o ConnectTimeout=%ld", (long)connectionTimeout]]; @@ -347,6 +346,13 @@ // Listen for output [task waitUntilExit]; + + // On tunnel close, clean up, ready for re-use if the delegate reconnects. + [task release], task = nil; + [standardError release], standardError = nil; + [[NSNotificationCenter defaultCenter] removeObserver:self + name:@"NSFileHandleDataAvailableNotification" + object:nil]; // If the task closed unexpectedly, alert appropriately if (connectionState != PROXY_STATE_IDLE) { @@ -356,16 +362,9 @@ if (delegate) [delegate performSelectorOnMainThread:stateChangeSelector withObject:self waitUntilDone:NO]; } - // On tunnel close, clean up - [[NSNotificationCenter defaultCenter] removeObserver:self - name:@"NSFileHandleDataAvailableNotification" - object:nil]; - // Run the run loop for a short time to ensure all task/pipe callbacks are dealt with [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0]]; - [task release], task = nil; - [standardError release], standardError = nil; [taskEnvironment release], taskEnvironment = nil; [taskArguments release], taskArguments = nil; -- cgit v1.2.3