From 355c209d75793ed7a845cd9c73261a5c32732294 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Fri, 28 Oct 2011 22:41:07 +0000 Subject: - Fix an issue in MCPConnection causing connection locking if the connection has an active query and is performing actions such as encoding conversions --- Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'Frameworks') 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]; -- cgit v1.2.3