aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/MCPKit
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2010-11-12 01:09:34 +0000
committerrowanbeentje <rowan@beent.je>2010-11-12 01:09:34 +0000
commit443f8e030ef2bd9e08e82ef45b6c93416124f8de (patch)
treef1294337a14d1baa71c2126f9b49ccf0640bb66c /Frameworks/MCPKit
parente83978c06efee794faa0603c6e6653fd1647b26a (diff)
downloadsequelpro-443f8e030ef2bd9e08e82ef45b6c93416124f8de.tar.gz
sequelpro-443f8e030ef2bd9e08e82ef45b6c93416124f8de.tar.bz2
sequelpro-443f8e030ef2bd9e08e82ef45b6c93416124f8de.zip
- Tweak connection/reconnection to use locking, to prevent race condition issues when reconnecting after a network loss causing a drop in connection and proxy at the same time.
Diffstat (limited to 'Frameworks/MCPKit')
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m8
1 files changed, 7 insertions, 1 deletions
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
index a9973e82..af203222 100644
--- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
+++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
@@ -406,6 +406,8 @@ static BOOL sTruncateLongFieldInLogs = YES;
if (mConnection == NULL) return NO;
}
+ [self lockConnection];
+
if (mConnection != NULL) {
// Ensure the custom timeout option is set
@@ -457,8 +459,9 @@ static BOOL sTruncateLongFieldInLogs = YES;
thePass = NULL;
if (theRet != mConnection) {
+ [self unlockConnection];
[self setLastErrorMessage:nil];
-
+
lastQueryErrorId = mysql_errno(mConnection);
return mConnected = NO;
@@ -477,6 +480,7 @@ static BOOL sTruncateLongFieldInLogs = YES;
encodingUsesLatin1Transport = NO;
[self setLastErrorMessage:nil];
connectionThreadId = mConnection->thread_id;
+ [self unlockConnection];
[self timeZone]; // Getting the timezone used by the server.
// Only attempt to set the max allowed packet if we have a connection
@@ -578,6 +582,7 @@ static BOOL sTruncateLongFieldInLogs = YES;
mConnected = NO;
isDisconnecting = NO;
+ [self lockConnection];
// If no network is present, loop for a short period waiting for one to become available
uint64_t elapsedTime_t, networkWaitStartTime_t = mach_absolute_time();
@@ -642,6 +647,7 @@ static BOOL sTruncateLongFieldInLogs = YES;
[connectionProxy setConnectionStateChangeSelector:@selector(connectionProxyStateChange:) delegate:self];
}
+ [self unlockConnection];
if (!connectionProxy || [connectionProxy state] == PROXY_STATE_CONNECTED) {
// Attempt to reinitialise the connection - if this fails, it will still be set to NULL.