diff options
author | rowanbeentje <rowan@beent.je> | 2010-01-27 01:04:03 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2010-01-27 01:04:03 +0000 |
commit | b36564545f2290e7e41a794c33783e6ce322bbcc (patch) | |
tree | 34dae44e3fd56b88154e8411e0b43407b0c7fb76 /Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m | |
parent | 9987c0cb9440fea045d56ece1dd8cdd0828c9820 (diff) | |
download | sequelpro-b36564545f2290e7e41a794c33783e6ce322bbcc.tar.gz sequelpro-b36564545f2290e7e41a794c33783e6ce322bbcc.tar.bz2 sequelpro-b36564545f2290e7e41a794c33783e6ce322bbcc.zip |
- Fix SSH threads (and connections) which were never cleaned up or closed, probably as a result of r1709
- Improve SSH and object cleanup, especially for cases where the connection drops, to ensure the connection proxy is cleaned up and all memory released
Diffstat (limited to 'Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m')
-rw-r--r-- | Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m index 7a3c9c8c..d112189f 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m @@ -103,6 +103,7 @@ static BOOL sTruncateLongFieldInLogs = YES; lastQueryExecutedAtTime = CGFLOAT_MAX; queryCancelled = NO; queryCancelUsedReconnect = NO; + serverVersionString = nil; // Initialize ivar defaults connectionTimeout = 10; @@ -372,20 +373,13 @@ static BOOL sTruncateLongFieldInLogs = YES; } mConnected = NO; - + if (connectionProxy) { [connectionProxy disconnect]; } - if (serverVersionString != nil) { - [serverVersionString release]; - serverVersionString = nil; - } - - if (theDbStructure != nil) { - [theDbStructure release]; - theDbStructure = nil; - } + if (serverVersionString) [serverVersionString release], serverVersionString = nil; + if (theDbStructure) [theDbStructure release], theDbStructure = nil; [self stopKeepAliveTimer]; } @@ -2382,12 +2376,25 @@ void performThreadedKeepAlive(void *ptr) { delegate = nil; + // Release the query lock, after unlocking it + [queryLock tryLock]; + [queryLock unlock]; + [queryLock release]; + + // Clean up connections if necessary + if (mConnected) [self disconnect]; + if (connectionProxy) { + [connectionProxy setConnectionStateChangeSelector:NULL delegate:nil]; + [connectionProxy disconnect]; + } + if (lastQueryErrorMessage) [lastQueryErrorMessage release]; if (connectionHost) [connectionHost release]; if (connectionLogin) [connectionLogin release]; if (connectionSocket) [connectionSocket release]; if (connectionPassword) [connectionPassword release]; - [queryLock release]; + if (serverVersionString) [serverVersionString release], serverVersionString = nil; + if (theDbStructure) [theDbStructure release], theDbStructure = nil; [super dealloc]; } |