aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/MCPKit/MCPFoundationKit
diff options
context:
space:
mode:
Diffstat (limited to 'Frameworks/MCPKit/MCPFoundationKit')
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m18
1 files changed, 17 insertions, 1 deletions
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
index f40d79e8..3be896b1 100644
--- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
+++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
@@ -761,7 +761,23 @@ static BOOL sTruncateLongFieldInLogs = YES;
if (!mConnected) return NO;
BOOL connectionVerified = FALSE;
-
+
+ // If the connection is currently locked, it's probably in use - no need to check
+ // the connection.
+ if ([connectionLock condition] == MCPConnectionBusy) {
+
+ // However if a ping thread is active, might be a background ping - wait for it
+ // to complete, then check the connection.
+ if (pingThreadActive) {
+ while (pingThreadActive) {
+ usleep(10000);
+ }
+ return [self checkConnection];
+ }
+
+ return YES;
+ }
+
// Check whether the connection is still operational via a wrapped version of MySQL ping.
connectionVerified = [self pingConnectionUsingLoopDelay:400];