diff options
author | stuconnolly <stuart02@gmail.com> | 2010-12-08 19:03:47 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2010-12-08 19:03:47 +0000 |
commit | 61e398816badc49b301a6ae70c3697d581258cfb (patch) | |
tree | cca1e18f88c42556b4a5e48c1e685cb2b6574b78 /Frameworks/MCPKit | |
parent | 3fccc9c751cded1360aa22796ed3c6d700fd04c1 (diff) | |
parent | 5b88ac6a6d0c02b1b51f295cf79e84b61c1f1bd5 (diff) | |
download | sequelpro-61e398816badc49b301a6ae70c3697d581258cfb.tar.gz sequelpro-61e398816badc49b301a6ae70c3697d581258cfb.tar.bz2 sequelpro-61e398816badc49b301a6ae70c3697d581258cfb.zip |
Bring outline view branch up to date with trunk (r2976:2988).
Diffstat (limited to 'Frameworks/MCPKit')
-rw-r--r-- | Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h | 1 | ||||
-rw-r--r-- | Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m | 20 |
2 files changed, 21 insertions, 0 deletions
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h index ad30fa07..61ce1261 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h @@ -57,6 +57,7 @@ typedef struct { BOOL useKeepAlive; BOOL isDisconnecting; + BOOL isReconnecting; BOOL userTriggeredDisconnect; NSInteger connectionTimeout; CGFloat keepAliveInterval; diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m index af203222..03cade24 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m @@ -141,6 +141,7 @@ static BOOL sTruncateLongFieldInLogs = YES; serverVersionString = nil; mTimeZone = nil; isDisconnecting = NO; + isReconnecting = NO; userTriggeredDisconnect = NO; automaticReconnectAttempts = 0; lastPingSuccess = NO; @@ -554,6 +555,22 @@ static BOOL sTruncateLongFieldInLogs = YES; NSString *currentEncoding = [NSString stringWithString:encoding]; BOOL currentEncodingUsesLatin1Transport = encodingUsesLatin1Transport; NSString *currentDatabase = nil; + + // Check whether a reconnection attempt is already being made - if so, wait and return the status of that reconnection attempt. + if (isReconnecting) { + NSDate *reconnectLoopStartdate = [NSDate date], *eventLoopStartDate; + while (isReconnecting) { + eventLoopStartDate = [NSDate date]; + [[NSRunLoop currentRunLoop] runMode:NSModalPanelRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; + if ([[NSDate date] timeIntervalSinceDate:eventLoopStartDate] < 0.1) { + usleep(100000 - (1000000 * [[NSDate date] timeIntervalSinceDate:eventLoopStartDate])); + } + } + [reconnectionPool drain]; + return mConnected; + } + + isReconnecting = YES; // Store the currently selected database so it can be re-set if reconnection was successful if (delegate && [delegate respondsToSelector:@selector(onReconnectShouldSelectDatabase:)] && [delegate onReconnectShouldSelectDatabase:self]) { @@ -689,14 +706,17 @@ static BOOL sTruncateLongFieldInLogs = YES; [self setLastErrorMessage:NSLocalizedString(@"User triggered disconnection", @"User triggered disconnection")]; userTriggeredDisconnect = YES; [reconnectionPool release]; + isReconnecting = NO; return NO; default: [reconnectionPool release]; + isReconnecting = NO; return [self reconnect]; } } [reconnectionPool release]; + isReconnecting = NO; return mConnected; } |